#ifndef BINTREE_H #define BINTREE_H #include typedef int (*CompareFctType)(const void *arg1, const void *arg2); typedef struct node { void *data; struct node *left; struct node *right; } TreeNode; // Adds a copy of data's pointer destination to the tree using compareFct for ordering. // Accepts duplicates if isDuplicate is NULL. Otherwise duplicates are ignored and // isDuplicate is set to 1. If a new entry is added, isDuplicate is set to 0. TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFctType compareFct, int *isDuplicate); // Iterates over the tree in sorted order. If root is not NULL, a new iteration starts. // If root is NULL, the next entry of the last tree is returned. void *nextTreeData(TreeNode *root); // Releases all memory resources, including data copies. void clearTree(TreeNode *root); // Returns the number of entries in the tree given by root. unsigned int treeSize(const TreeNode *root); #endif