The abstract class Iterator is used to provide an interface with which one can conveniently iterate through a list or array. It depends on the implementation which data is obtained.
More...
|
| virtual bool | hasNext () noexcept=0 |
| | This method checks if the list contains another element.
|
| |
| virtual Object * | next () noexcept=0 |
| | This method iterates to the next element in the list and returns it.
|
| |
| virtual | ~Iterator () noexcept=default |
| |
The abstract class Iterator is used to provide an interface with which one can conveniently iterate through a list or array. It depends on the implementation which data is obtained.
- Note
- With initialisation of the list, the pointer to the elements precedes the first element, so that the first call to next() actually returns the first element.
◆ ~Iterator()
| virtual jm::Iterator::~Iterator |
( |
| ) |
|
|
virtualdefaultnoexcept |
◆ hasNext()
| virtual bool jm::Iterator::hasNext |
( |
| ) |
|
|
pure virtualnoexcept |
This method checks if the list contains another element.
- Returns
- "true" if there is at least one more element in the list, otherwise "false".
Implemented in jm::LinkedListIterator.
◆ next()
| virtual Object * jm::Iterator::next |
( |
| ) |
|
|
pure virtualnoexcept |
This method iterates to the next element in the list and returns it.
- Returns
- A pointer to the next element in the list. Returns nullptr, if end if list reached
Implemented in jm::LinkedListIterator.