|
TreeMap | newTree (int(*keyComp)(void *, void *)) |
| Creates a tree. More...
|
|
int | treeSetKComp (TreeMap tree, int(*keyComp)(void *, void *)) |
| Sets the comparison function of this tree. More...
|
|
void | treeDelete (TreeMap tree) |
| Deletes a tree. More...
|
|
int | treeInsert (TreeMap tree, void *key, void *value, int replace) |
| Associates a value to a key in a tree. More...
|
|
int | treeRemove (TreeMap tree, void *key, void **value, void(*del)(void *)) |
| Removes the mapping for a key from a tree. More...
|
|
int | treeGet (TreeMap tree, void *key, void **value) |
| Provides the mapping for a key from a tree. More...
|
|
int | treeIsBalanced (TreeMap tree) |
| Checks if a tree is balanced. More...
|
|
int | treeHeight (TreeMap tree) |
| Returns the height of a tree. More...
|
|
int | treeSize (TreeMap tree) |
| Returns the number of elements present in a tree. More...
|
|
int | treeInOrder (TreeMap tree, void(*fun)(void *, void *)) |
| Applies a function to the elements of an tree (inorder traversal). More...
|
|
int | treePreOrder (TreeMap tree, void(*fun)(void *, void *)) |
| Applies a function to the elements of an tree (preorder traversal). More...
|
|
int | treePostOrder (TreeMap tree, void(*fun)(void *, void *)) |
| Applies a function to the elements of an tree (postorder traversal). More...
|
|
Iterator | treeKeys (TreeMap tree) |
| Creates an iterator from the keys of a tree. More...
|
|
Iterator | treeValues (TreeMap tree) |
| Creates an iterator from the values of a tree. More...
|
|
Implementation of an AVL tree (self-balancing binary search tree).
Provides functions to create and manipulate an AVL tree.
To use this tree you have to provide the following function for the date type used for keys:
int keyComp(void* key1,void* key2)
Compares two keys (used by treeInsert
, treeRemove
, and treeGet
). It should return 0 if key1
is equal to key2
, a value less than 0 if key1
is less than key2
, and a value greater than 0 if key1
is greater than 0. This function can be changed using function treeSetKComp
.
int keyComp(void* key1,void* key2)
{
if(key1&&key2) return strcmp((char*)key1,(char*)key2);
else return 0;
}
- Author
- Rui Carlos Gonçalves
- Version
- 3.0
- Date
- 07/2012
Definition in file treemap.h.
int treeGet |
( |
TreeMap |
tree, |
|
|
void * |
key, |
|
|
void ** |
value |
|
) |
| |
Provides the mapping for a key from a tree.
If there is no mapping for the specified key, it will be put the value NULL
at value
. However, the NULL
value may also say that the mapping for the specified key was NULL
. Check the returned value in order to know whether the key was in the tree.
- Attention
- This function puts at
value
a pointer to the mapping of the specified key. Changes to this value will affect the value in the tree.
- Parameters
-
tree | the tree |
key | key whose mapping is to be provided |
value | pointer where the mapping value will be put |
- Returns
- 0 if there was a mapping for the specified key
1 otherwise
Definition at line 550 of file treemap.c.