Main Page Modules Class Hierarchy Compound List File List Compound Members
cQueue Class Reference
#include <cqueue.h>
Inheritance diagram for cQueue::
List of all members.
Detailed Description
Queue class. cQueue is a container class that can hold objects derived from cObject. cQueue acts as a priority queue. The user must provide a function that can compare two objects. If no such function is given, cQueue implements a FIFO. Order (ascending or descending) can be specified.
Ownership of contained objects (responsibility of deletion) can be specified per-object basis (see cObject::takeOwnership()). Default is that cQueue takes the ownership of each object inserted (that is, takeOwnership(true)).
The sorting function should look like: int CompareFunc(cObject* a, cObject* b);
They must return a negative value if a<b, 0 if a==b and a positive value if a>b.
-
See also:
-
cQueueIterator
Constructor & Destructor Documentation
cQueue::cQueue (
|
const cQueue & queue )
|
|
|
Copy constructor. Contained objects that are owned by the queue will be duplicated so that the new queue will have its own copy of them. |
cQueue::cQueue (
|
const char * name = NULL,
|
|
CompareFunc cmp = NULL,
|
|
bool a = false ) [explicit]
|
|
|
Constructor. It accepts the object name, the address of the comparing function and the sorting order (ascending=true, descending=false). |
cQueue::~cQueue (
|
) [virtual]
|
|
|
Destructor. Deletes all contained objects that were owned by it. |
Member Function Documentation
const char * cQueue::className (
|
) const [inline, virtual]
|
|
|
Returns pointer to a string containing the class name, "cQueue".
Reimplemented from cObject. |
void cQueue::clear (
|
) [virtual]
|
|
|
As a result, the container will be empty. Contained objects that were owned by the queue will be deleted. |
bool cQueue::contains (
|
cObject * obj ) const [virtual]
|
|
|
Returns true if the queue contains the passed object. |
cObject * cQueue::dup (
|
) const [inline, virtual]
|
|
|
Duplication and assignment work all right with cQueue. Contained objects that are owned by the queue will be duplicated so that the new queue will have its own copy of them.
Reimplemented from cObject. |
bool cQueue::empty (
|
) const [inline]
|
|
|
Returns true if the queue is empty. |
void cQueue::forEach (
|
ForeachFunc f ) [virtual]
|
|
|
Calls the given function for each contained object.
Reimplemented from cObject. |
cObject * cQueue::head (
|
) const [virtual]
|
|
|
Returns pointer to the object at the head of the queue. Returns NULL if the queue is empty. |
void cQueue::info (
|
char * buf ) [virtual]
|
|
|
Produces a one-line description of object contents into the buffer passed as argument. See cObject for more details.
Reimplemented from cObject. |
void cQueue::insert (
|
cObject * obj ) [virtual]
|
|
|
Inserts the given object into the queue, maintaining the sorting order. Trying to insert a NULL pointer is an error. |
|
Inserts exactly after the given object. If the given position does not exist, an error is raised. Trying to insert a NULL pointer is also an error. |
void cQueue::insertBefore (
|
cObject * where,
|
|
cObject * obj ) [virtual]
|
|
|
Inserts exactly before the given object. If the given position does not exist, an error is raised. Trying to insert a NULL pointer is also an error. |
const char * cQueue::inspectorFactoryName (
|
) const [inline, virtual]
|
|
|
Returns the name of the inspector factory class associated with this class. See cObject for more details.
Reimplemented from cObject. |
int cQueue::length (
|
) const [virtual]
|
|
|
Returns the number of objects contained in the queue. |
int cQueue::netPack (
|
) [virtual]
|
|
|
Serializes the object into a PVM or MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details.
Reimplemented from cObject. |
int cQueue::netUnpack (
|
) [virtual]
|
|
|
Deserializes the object from a PVM or MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details.
Reimplemented from cObject. |
cQueue & cQueue::operator= (
|
const cQueue & queue )
|
|
|
Assignment operator. Duplication and assignment work all right with cQueue. Contained objects that are owned by the queue will be duplicated so that the new queue will have its own copy of them.
The name member doesn't get copied; see cObject's operator=() for more details. |
cObject * cQueue::pop (
|
) [virtual]
|
|
|
Unlinks and returns the last (tail) object in the queue. If the queue was empty, an error is raised. |
|
Unlinks and returns the object given. If the object is not in the queue, a warning is issued and the same pointer is returned. |
void cQueue::setup (
|
CompareFunc cmp,
|
|
bool a = false ) [virtual]
|
|
|
Changes the sort function and the sorting order. Doesn't re-sort the contents of the queue! |
cObject * cQueue::tail (
|
) const [virtual]
|
|
|
Returns pointer to the last (tail) object in the queue. Returns NULL if the queue is empty. |
The documentation for this class was generated from the following file:
Generated at Sat May 4 15:45:51 2002 for OMNeT++ by
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001