class ListIterator

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

Full nameTelEngine::ListIterator
Definition#include <yateclass.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

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.

 ListIterator (ObjList& list)

ListIterator

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

Parameters:
listList to get the objects from

 ListIterator (HashList& list)

ListIterator

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

Parameters:
listList to get the objects from

 ~ListIterator ()

~ListIterator

Destructor - frees the allocated memory

inline unsigned int  length ()

length

[const]

Get the number of elements in the list

Returns: Count of items in the internal list

GenObject*  get (unsigned int index)

get

[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:
indexPosition to get the item from

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

GenObject*  get ()

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)

inline bool  eof ()

eof

[const]

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

Returns: True if there are no more entries left

inline void  reset ()

reset

Reset the iterator index to the first position in the list


Generated by: root on dragoshel on Sat Apr 14 01:50:50 2007, using kdoc 2.0a54.