Iterator Class Reference¶
|
API
|
Public Member Functions | |
| Iterator (const cArray &a, bool atHead=true) | |
| void | init (const cArray &a, bool atHead=true) |
| cObject * | operator* () const |
| bool | end () const |
| Iterator & | operator++ () |
| Iterator | operator++ (int) |
| Iterator & | operator-- () |
| Iterator | operator-- (int) |
Description
Iterates through elements in a cArray, skipping holes (slots containing nullptr).
Usage:
Constructor & Destructor Documentation
◆ Iterator()
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.
References cArray::cArray(), and init().
Referenced by operator++(), operator++(), operator--(), and operator--().
Member Function Documentation
◆ init()
| void init | ( | const cArray & | a, |
| bool | atHead = true ) |
◆ operator*()
|
inline |
Returns a pointer to the current object, or nullptr if the iterator is not at a valid position.
◆ end()
|
inline |
Returns true if the iterator has reached either end of the array.
Referenced by operator++(), operator++(), operator--(), and operator--().
◆ operator++() [1/2]
|
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.
References end(), and Iterator().
◆ operator++() [2/2]
|
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.
References end(), and Iterator().
◆ operator--() [1/2]
|
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.
References end(), and Iterator().
◆ operator--() [2/2]
|
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.
References end(), and Iterator().
Generated on for API by