# cMessageHeap Class Reference
[Internal classes]

`#include <cmsgheap.h>`

Inheritance diagram for cMessageHeap:

List of all members.

## Detailed Description

Stores the future event set.

The underlying data structure is heap; the array used to store the heap expands as needed.

See also:
  Iterator

## Public Member Functions

Constructors, destructor, assignment
| cMessageHeap (const cMessageHeap &msgq)
| cMessageHeap (const char *name=NULL, int size=128)
virtual | ~cMessageHeap ()
cMessageHeap & | operator= (const cMessageHeap &msgqueue)
Redefined cObject member functions.
virtual cPolymorphic * | dup () const
virtual std::string | info () const
virtual void | forEachChild (cVisitor *v)
Container functions.
void | insert (cMessage *event)
cMessage * | peekFirst () const
cMessage * | getFirst ()
cMessage * | get (cMessage *event)
cMessage * | peek (int m)
void | sort ()
void | clear ()
int | length () const
bool | empty () const

## Classes

class | Iterator
| Walks along a cMessageHeap. More...

## Constructor & Destructor Documentation

cMessageHeap::cMessageHeap | ( | const cMessageHeap & | msgq | ) |

| Copy constructor.

cMessageHeap::cMessageHeap | ( | const char * | name = `NULL`,
|  | int | size = `128`
| ) |

| Constructor.

virtual cMessageHeap::~cMessageHeap | ( |  | ) | `[virtual]`

| Destructor.

## Member Function Documentation

void cMessageHeap::clear | ( |  | ) |

| Deletes all messages in the heap.

virtual cPolymorphic* cMessageHeap::dup | ( |  | ) | const`[inline, virtual]`

| Creates and returns an exact copy of this object. See cObject for more details. Reimplemented from cObject.

bool cMessageHeap::empty | ( |  | ) | const`[inline]`

| Returns true if the heap is empty.

virtual void cMessageHeap::forEachChild | ( | cVisitor * | v | ) | `[virtual]`

| Calls v->visit(this) for each contained object. See cObject for more details. Reimplemented from cObject.

cMessage* cMessageHeap::get | ( | cMessage * | event | ) |

| Removes and returns the given message in the heap. If the message is not in the heap, returns NULL.

cMessage* cMessageHeap::getFirst | ( |  | ) |

| Removes and return the first message in the heap (the one with the smallest timestamp. ) If the heap is empty, it returns NULL.

virtual std::string cMessageHeap::info | ( |  | ) | const`[virtual]`

| Produces a one-line description of object contents into the buffer passed as argument. See cObject for more details. Reimplemented from cPolymorphic.

void cMessageHeap::insert | ( | cMessage * | event | ) |

| Insert a new message into the heap.

int cMessageHeap::length | ( |  | ) | const`[inline]`

| Returns the number of messages in the heap.

cMessageHeap& cMessageHeap::operator= | ( | const cMessageHeap & | msgqueue | ) |

| Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details.

cMessage* cMessageHeap::peek | ( | int | m | ) |

| Returns the mth message in the heap if 0 <= m < length(), and NULL otherwise. Note that iteration does not necessarily return messages in increasing timestamp (arrivalTime()) order unless you called sort() before.

cMessage* cMessageHeap::peekFirst | ( |  | ) | const

| Peek the first message in the heap (the one with the smallest timestamp. ) If the heap is empty, it returns NULL.

void cMessageHeap::sort | ( |  | ) |

| Sorts the contents of the heap. This is only necessary if one wants to iterate through in the FES in strict timestamp order.

The documentation for this class was generated from the following file:

- cmsgheap.h