aboutsummaryrefslogtreecommitdiff
path: root/comp2521/tf_idf/fileList.h
blob: e7afb548ef7d90459dce3ad0078444cb6ceafca2 (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
#ifndef FILELIST_C_
#define FILELIST_C_

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

#include "invertedIndex.h"

// Forward declaration for strdup in <string.h>
char *strdup(const char *);

/*
 * File list node is unfortuntely defined in "invertedIndex.h":
    struct FileListNode {
        char *filename;
        double tf; // relative tf
        struct FileListNode *next;
    };
*/

// Returns a newly malloc'ed file list node, with fields initialised to zero.
struct FileListNode *createFileListNode();

// Appends a FileListNode to the end of a FileListNode linked list.
struct FileListNode *insertFileList(struct InvertedIndexNode *head,
                                    char *const word);

// Inserts a fileListNode into a list via ordering of tf values. If the tf
// values are equal, inserts based off the filename in ascending order.
// Returns the new head of the list.
struct FileListNode *insertFileOrderedList(struct FileListNode *head,
                                           struct FileListNode *insert,
                                           double mult);
#endif