MQTT C Client Libraries Internals
Macros | Functions
Tree.c File Reference

functions which apply to tree structures. More...

#include "Tree.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "Heap.h"
Include dependency graph for Tree.c:

Macros

#define TREE_C   /* so that malloc/free/realloc aren't redefined by Heap.h */
 
#define LEFT   0
 
#define RIGHT   1
 
#define max(a, b)   (a > b) ? a : b;
 

Functions

int isRed (Node *aNode)
 
int isBlack (Node *aNode)
 
void TreeRotate (Tree *aTree, Node *curnode, int direction, int index)
 
NodeTreeBAASub (Tree *aTree, Node *curnode, int which, int index)
 
void TreeBalanceAfterAdd (Tree *aTree, Node *curnode, int index)
 
void * TreeAddByIndex (Tree *aTree, void *content, size_t size, int index)
 Add an item to a tree. More...
 
NodeTreeFindIndex1 (Tree *aTree, void *key, int index, int value)
 
NodeTreeFindContentIndex (Tree *aTree, void *key, int index)
 
NodeTreeMinimum (Node *curnode)
 
NodeTreeSuccessor (Node *curnode)
 
NodeTreeNextElementIndex (Tree *aTree, Node *curnode, int index)
 
NodeTreeBARSub (Tree *aTree, Node *curnode, int which, int index)
 
void TreeBalanceAfterRemove (Tree *aTree, Node *curnode, int index)
 
void * TreeRemoveIndex (Tree *aTree, void *content, int index)
 Remove an item from a tree. More...
 
void TreeInitializeNoMalloc (Tree *aTree, int(*compare)(void *, void *, int))
 
TreeTreeInitialize (int(*compare)(void *, void *, int))
 Allocates and initializes a new tree structure. More...
 
void TreeAddIndex (Tree *aTree, int(*compare)(void *, void *, int))
 
void TreeFree (Tree *aTree)
 
void * TreeAdd (Tree *aTree, void *content, size_t size)
 
NodeTreeFindIndex (Tree *aTree, void *key, int index)
 
NodeTreeFind (Tree *aTree, void *key)
 
NodeTreeNextElement (Tree *aTree, Node *curnode)
 
void * TreeRemoveNodeIndex (Tree *aTree, Node *curnode, int index)
 Remove an item from a tree. More...
 
void * TreeRemove (Tree *aTree, void *content)
 
void * TreeRemoveKeyIndex (Tree *aTree, void *key, int index)
 
void * TreeRemoveKey (Tree *aTree, void *key)
 
int TreeIntCompare (void *a, void *b, int content)
 
int TreePtrCompare (void *a, void *b, int content)
 
int TreeStringCompare (void *a, void *b, int content)
 

Detailed Description

functions which apply to tree structures.

These trees can hold data of any sort, pointed to by the content pointer of the Node structure.

Function Documentation

◆ TreeAddByIndex()

void * TreeAddByIndex ( Tree aTree,
void *  content,
size_t  size,
int  index 
)

Add an item to a tree.

Parameters
aTreethe list to which the item is to be added
contentthe list item content itself
sizethe size of the element
Here is the call graph for this function:

◆ TreeInitialize()

Tree* TreeInitialize ( int(*)(void *, void *, int)  compare)

Allocates and initializes a new tree structure.

Returns
a pointer to the new tree structure
Here is the call graph for this function:

◆ TreeRemoveIndex()

void * TreeRemoveIndex ( Tree aTree,
void *  content,
int  index 
)

Remove an item from a tree.

Parameters
aTreethe list to which the item is to be added
curnodethe list item content itself

◆ TreeRemoveNodeIndex()

void* TreeRemoveNodeIndex ( Tree aTree,
Node curnode,
int  index 
)

Remove an item from a tree.

Parameters
aTreethe list to which the item is to be added
curnodethe list item content itself