// This module implements a binary tree to keep track of messages that
// have already been seen so that they don't need to be read again.
extern "C" {
#include <stdio.h>
#include <stdlib.h>
}
#include "string.h"
#include "common.h"
typedef class treeNode *treeP;
class treeNode {
public:
treeNode(char *);
treeNode(FILE *, int, int);
int inTree(char *);
void saveNode(FILE *);
void printNode();
void printDepth(int d);
~treeNode() { free(value); free(left); free(right); }
private:
char *value;
treeP left, right;
};
typedef class binaryTree *bTreeP;
class binaryTree {
public:
binaryTree() { groupName = NULL; root = NULL; addsSinceLastSave = 0; }
void setGroupName(char *name) { groupName = strdup(name); }
void saveTree();
void loadTree();
void printTree();
int inTree(char *id);
void printDepth();
~binaryTree() { free(groupName); free(root); }
private:
char *groupName;
treeP root;
int addsSinceLastSave;
void checkSave();
};
syntax highlighted by Code2HTML, v. 0.9.1