OMNeT++ Simulation Library  6.0.3
cArray::Iterator Class Reference

#include <carray.h>

Description

Iterates through elements in a cArray, skipping holes (slots containing nullptr).

Usage:

for (cArray::Iterator it(array); !it.end(); ++it) {
cObject *item = *it;
...
}

Public Member Functions

 Iterator (const cArray &a, bool atHead=true)
 
void init (const cArray &a, bool atHead=true)
 
cObjectoperator* () const
 
bool end () const
 
Iteratoroperator++ ()
 
Iterator operator++ (int)
 
Iteratoroperator-- ()
 
Iterator operator-- (int)
 

Constructor & Destructor Documentation

◆ Iterator()

Iterator ( const cArray a,
bool  atHead = true 
)
inline

Constructor. Iterator will walk on the array passed as argument. The starting object will be the first (if atHead==true) or the last (atHead==false) object in the array, not counting empty slots.

Member Function Documentation

◆ init()

void init ( const cArray a,
bool  atHead = true 
)

Reinitializes the iterator object.

◆ operator*()

cObject* operator* ( ) const
inline

Returns a pointer to the current object, or nullptr if the iterator is not at a valid position.

References cArray::get().

◆ end()

bool end ( ) const
inline

Returns true if the iterator has reached either end of the array.

References cArray::size().

◆ operator++() [1/2]

Iterator& operator++ ( )
inline

Prefix increment operator (++it). Moves the iterator to the next non-empty slot in the array. It has no effect if the iterator has reached either end of the array.

◆ operator++() [2/2]

Iterator operator++ ( int  )
inline

Postfix increment operator (it++). Moves the iterator to the next non-empty slot in the array, and returns the iterator's previous state. It has no effect if the iterator has reached either end of the array.

◆ operator--() [1/2]

Iterator& operator-- ( )
inline

Prefix decrement operator (–it). Moves the iterator to the previous non-empty slot in the array. It has no effect if the iterator has reached either end of the array.

◆ operator--() [2/2]

Iterator operator-- ( int  )
inline

Postfix decrement operator (it–). Moves the iterator to the previous non-empty slot in the array, and returns the iterator's previous state. It has no effect if the iterator has reached either end of the array.


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