- Inherits from:
- Object
- Declared in:
- DAvlTree.h
Object
|
+---DAvlIterator
Class Description
The DAvlIterator class contains a number of methods for iterating a avl tree.
- Example:
#include <stdio.h>
#include "ofc/DAvlTree.h"
int main(int argc, char *argv[])
{
DAvlTree *tree = [DAvlTree alloc];
DAvlIterator *iter = [DAvlIterator alloc];
DText *key;
DText *value;
[tree init :[DText class]]; // Init tree, key is a DText object
// Insert DText keys and values in the tree ...
[iter init :tree]; // Init the iterator with the tree
key = [iter key];
while (key != nil) // Iterate the tree
{
val = [iter object];
[iter next];
key = [iter key];
}
[iter free]; // Cleanup
[tree free];
[key free];
return 0;
}
- Last modified:
- 19-Jul-2008 (DAvlTree.h)
Instance Variables
- private DAvlTree *_tree
- the tree on which the iterator operates
- private DAvlNode *_node
- the current node in the list
- the constructors
- - (DAvlIterator *) init
- Initialises an avl tree iterator without a tree
- Returns:
- the iterator
- - (DAvlIterator *) init :(DAvlTree *) tree
- Initialises an iterator on a tree (the iterator is moved to the first node)
- Parameters:
- tree - the tree on which the iterator operates
- Returns:
- the iterator
- the iterator methods
- - (id) first
- Get the first object in the tree
- Returns:
- a reference to the first object (or nil)
- - (id) key
- Get the key of the current object
- Returns:
- a referencee to the key of the current object (or nil)
- - (id) last
- Get the last object in the tree
- Returns:
- the last object (or nil)
- - (id) next
- Get the next object in the tree
- Returns:
- the next object (or nil)
- - (id) object
- Get the current object
- Returns:
- the current object (or nil)
- - (id) object :(id) object
- Set the current object to another object
- Parameters:
- object - the object to be placed in current node
- Returns:
- the previous stored object
- - (id) prev
- Get the previous object in the tree
- Returns:
- the previous object (or nil)
- - (DAvlIterator *) tree :(DAvlTree *) tree
- Set the avl tree (iterator is moved to the first object)
- Returns:
- the object
generated 06-Sep-2008 by ObjcDoc 3.0.0