Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
jm::Iterator Class Referenceabstract

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...

Inheritance diagram for jm::Iterator:
jm::LinkedListIterator

Public Member Functions

virtual bool hasNext () noexcept=0
 This method checks if the list contains another element.
 
virtual Objectnext () noexcept=0
 This method iterates to the next element in the list and returns it.
 
virtual ~Iterator () noexcept=default
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~Iterator()

virtual jm::Iterator::~Iterator ( )
virtualdefaultnoexcept

Member Function Documentation

◆ 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.