From 98cef5e9a772602d42acfcf233838c760424db9a Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Thu, 13 Feb 2025 18:00:17 +1100 Subject: initial commit --- comp2521/tf_idf/invertedIndexTree.h | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 comp2521/tf_idf/invertedIndexTree.h (limited to 'comp2521/tf_idf/invertedIndexTree.h') diff --git a/comp2521/tf_idf/invertedIndexTree.h b/comp2521/tf_idf/invertedIndexTree.h new file mode 100644 index 0000000..29f93c5 --- /dev/null +++ b/comp2521/tf_idf/invertedIndexTree.h @@ -0,0 +1,38 @@ +#ifndef INVERTEDINDEXTREE_H_ +#define INVERTEDINDEXTREE_H_ + +#include +#include +#include + +#include "invertedIndex.h" + +/* + * invertedIndexTree is a binary search tree of the following struct, defined + * in invertedIndex.h": + struct InvertedIndexNode { + char *word; // key + struct FileListNode *fileList; + struct InvertedIndexNode *left; + struct InvertedIndexNode *right; + + }; +*/ + +// Returns a newly malloc'ed inverted index node, fields initialised to zero +// except for word. +struct InvertedIndexNode *createInvertedIndexNode(char *const word); + +// Inserts to a FileListNode BST. Uses strcmp to determine priority, with +// negative values moving into the left and positive values into the right. +struct InvertedIndexNode * +insertInvertedIndexNode(struct InvertedIndexNode *node, char *const word); + +// Searches for an invertedIndexNode based off the a word. +struct InvertedIndexNode * +searchInvertedIndexNode(struct InvertedIndexNode *node, char *const word); + +// Searches for an invertedIndexNode via a string. +struct InvertedIndexNode * +searchInvertedIndexNode(struct InvertedIndexNode *head, char *const word); +#endif -- cgit v1.2.3