- Inherits from:
- Object
- Declared in:
- DTree.h
Object
|
+---DTreeIterator
Class Description
The tree iterator class implements an iterator on a n-tree collection.
Because there is no key or index available to store and remove the objects,
the objects can only be stored and removed by this iterator.
- Last modified:
- 27-Feb-2005 (DTree.h)
Instance Variables
- private DTree *_tree
- the tree
- private DTreeNode *_node
- the current node
- Constructors
- - (DTreeIterator *) init
- Initialise an empty iterator
- Returns:
- the object
- - (DTreeIterator *) init :(DTree *) tree
- Initialise the iterator with a tree (iterator is moved to the root)
- Parameters:
- tree - the tree for the iterator (<> nil)
- Returns:
- the object
- Movement methods
- - (id) child
- Move to the first child (for the current parent)
- Returns:
- the object in the first child (or nil)
- - (id) first
- Move to the first child (in the list of childs)
- Returns:
- the object of the first child (or nil)
- - (id) last
- Move to the last child (in the list of childs)
- Returns:
- the object in the last node (or nil)
- - (BOOL) move :(id) obj
- Move the iterator to a certain object. The object is searched
from the root. If the object is not found, the iterator
remains on the same location as before calling this method.
If the object is found, the iterator is moved to this object.
- Parameters:
- obj - the object to be found
- Returns:
- is it found ?
- - (id) next
- Move to the next child (in the list of childs)
- Returns:
- the object of the next child (or nil)
- - (id) parent
- Move to the parent (for the current child)
- Returns:
- the object in the parent (or nil)
- - (id) prev
- Move to the previous child (in the list of childs)
- Returns:
- the object of the previous child (or nil)
- - (id) root
- Move to the root
- Returns:
- the object in the root (or nil)
- Test methods
- - (BOOL) hasChildren
- Test if the iterator is on a parent with children
- Returns:
- has it ?
- - (BOOL) isFirst
- Test if the iterator is on the first child (in the list of childs)
- Returns:
- is it ?
- - (BOOL) isLast
- Test if the iterator is on the last child (in the list of childs)
- Returns:
- is it ?
- - (BOOL) isRoot
- Test if the iterator is on the root
- Returns:
- is it ?
- Stored object methods
- - (id) object
- Get the object in the current node
- Returns:
- the object in the node (or nil)
- - (id) object :(id) obj
- Set the object in the current node
- Parameters:
- obj - the object to be set
- Returns:
- the previous object in the node
- AddInsertRemove methods
- - (DTreeIterator *) after :(id) obj
- Insert a new child after current (child) node (iterator is moved to new child)
- Parameters:
- obj - the object to be added as child
- Returns:
- the object
- - (DTreeIterator *) append :(id) obj
- Append a child to current (parent) node (iterator is moved to new child)
- Parameters:
- obj - the object to be added as child
- Returns:
- the object
- - (DTreeIterator *) before :(id) obj
- Insert a new child before current (child) node (iterator is moved to new child)
- Parameters:
- obj - the object to be added as child
- Returns:
- the object
- - (DTreeIterator *) prepend :(id) obj
- Prepend a child to the current (parent) node (iterator is moved to this new child)
- Parameters:
- obj - the object to be added as child
- Returns:
- the object
- - (id) remove
- Remove the current node
Note: only if current node has no children
Note: iterator moves to 1. the next child or 2. the previous child or 3. the parent
- Returns:
- the object from the current node (or nil)
generated 08-Jan-2006 by ObjcDoc 3.0.0