Yate

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
ListIterator Class Reference

Class used to iterate the items of a list. More...

`#include <yateclass.h>`

## Public Member Functions
| ListIterator (ObjList &list, int offset=0)
| ListIterator (HashList &list, int offset=0)
| ~ListIterator ()
unsigned int | length () const
void | clear ()
void | assign (ObjList &list, int offset=0)
void | assign (HashList &list, int offset=0)
GenObject * | get (unsigned int index) const
GenObject * | get ()
bool | eof () const
void | reset ()

## Detailed Description

Class used to iterate the items of a list.

An ObjList or HashList iterator that can be used even when list elements are changed while iterating. Note that it will not detect that an item was removed and another with the same address was inserted back in list.

## Constructor & Destructor Documentation

ListIterator | ( | ObjList & | list,
|  | int | offset = `0`
| ) |  |

Constructor used to iterate through an ObjList. The image of the list is frozen at the time the constructor executes

Parameters

  list | List to get the objects from
  offset | First list element to iterate, will wrap around

ListIterator | ( | HashList & | list,
|  | int | offset = `0`
| ) |  |

Constructor used to iterate through a HashList. The image of the list is frozen at the time the constructor executes

Parameters

  list | List to get the objects from
  offset | First list element to iterate, will wrap around

~ListIterator | ( |  | ) |

Destructor - frees the allocated memory

## Member Function Documentation

void assign | ( | ObjList & | list,
|  | int | offset = `0`
| ) |  |

Assign an ObjList to the iterator, build a frozen image of the list

Parameters

  list | List to get the objects from
  offset | First list element to iterate, will wrap around

void assign | ( | HashList & | list,
|  | int | offset = `0`
| ) |  |

Assign a HashList to the iterator, build a frozen image of the list

Parameters

  list | List to get the objects from
  offset | First list element to iterate, will wrap around

void clear | ( |  | ) |

Clear the iterator, disconnect from any list

bool eof | ( |  | ) | const
| inline

Check if the current pointer is past the end of the list

Returns
  True if there are no more entries left

GenObject* get | ( | unsigned int | index | ) | const

Get an arbitrary element in the iterator's list image. Items that were removed from list or are not alive are not returned.

Parameters

  index | Position to get the item from

Returns
  Pointer to the list item or NULL if out of range or item removed

GenObject* get | ( |  | ) |

Get the current element and advance the current index. Items that were removed from list or are not alive are skipped over. An example of typical usage:

    ListIterator iter(list);
    while (GenObject* obj = iter.get()) {
        do_something_with(obj);
    }

Returns
  Pointer to a list item or NULL if advanced past end (eof)

unsigned int length | ( |  | ) | const
| inline

Get the number of elements in the list

Returns
  Count of items in the internal list

void reset | ( |  | ) |
| inline

Reset the iterator index to the first position in the list

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

- yateclass.h