aboutsummaryrefslogtreecommitdiff
path: root/comp2521/tf_idf/invertedIndexTree.h
blob: 29f93c540e0d592f7cae69d357872cc0a82e4566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef INVERTEDINDEXTREE_H_
#define INVERTEDINDEXTREE_H_

#include <math.h>
#include <stdlib.h>
#include <string.h>

#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