-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.cpp
More file actions
57 lines (53 loc) · 1.15 KB
/
list.cpp
File metadata and controls
57 lines (53 loc) · 1.15 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Implementation file for Unsorted.h
#include <iostream>
#include <string>
#include "itemtype.h"
#include "word.h"
using namespace std;
void insert_file(Word* word_ptr, string filename)
{
word_ptr->wordTotal++;
if( !(word_ptr->file_ptr) )
{
word_ptr->file_ptr = new File(filename,1,NULL);
word_ptr->fileTotal++;
return;
}
File* iterator = word_ptr->file_ptr;
while(iterator->filename != filename && iterator->next)
iterator = iterator->next;
if(iterator->filename == filename)
iterator->count = iterator->count+1;
else{
iterator->next = new File(filename,1,NULL);
word_ptr->fileTotal++;
}
}
Word* insert_word(Word*& node, string search)
{
if (!node){
node = new Word(search);
return node;
}
else if (node->word == search)
return node;
else if(search < node->word)
return insert_word(node->left, search);
else
return insert_word(node->right, search);
}
Word* find_word(Word*& node, string search)
{
if (!node)
return NULL;
else if (node->word == search)
return node;
else if(search < node->word)
return find_word(node->left, search);
else
return find_word(node->right, search);
}
void print_all(Word* head)
{
//stub
}