-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLList.h
More file actions
100 lines (88 loc) · 1.8 KB
/
LList.h
File metadata and controls
100 lines (88 loc) · 1.8 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once
#include"List.h"
template<class DATATYPE>
//this uses my List.h and ListNode.h classes that I made. these interface with them
//this is so I can rely on one generalized templated linked list, then I can make tweeks to this
class LList
{
public:
LList();
~LList();
bool isEmpty();
void print();
int getLength();
bool insert(DATATYPE newData);
bool remove(DATATYPE oldData);
bool contains(DATATYPE target);
DATATYPE top();
bool clearList();
ListNode<DATATYPE>* find(DATATYPE target);
private:
List<DATATYPE>* head;
};
template<class DATATYPE>
LList<DATATYPE>::LList()
{ // new List
head = new List<DATATYPE>();
}
template<class DATATYPE>
LList<DATATYPE>::~LList()
{ //empties list in list.h
head->makeEmpty();
}
template<class DATATYPE>
bool LList<DATATYPE>::isEmpty()
{
if(head == NULL)
return true;
return false;
}
template<class DATATYPE>
void LList<DATATYPE>::print()
{
head->print();
}
template<class DATATYPE>
int LList<DATATYPE>::getLength()
{
return head->getLength();
}
template<class DATATYPE>
bool LList<DATATYPE>::insert(DATATYPE newData) //push back
{
return head->pushBack(newData);
}
template<class DATATYPE>
bool LList<DATATYPE>::remove(DATATYPE oldData)
{
return head->remove(oldData);
}
template<class DATATYPE>
bool LList<DATATYPE>::clearList()
{
if(head != NULL)
{
head->makeEmpty(); //deletes all node
head == NULL; //sets points to NULL
return true;
}
else
return false;
}
template<class DATATYPE>
bool LList<DATATYPE>::contains(DATATYPE target)
{
if(head->find(target) != NULL) //find returns a node, but I don't want that in this case
return true;
return false;
}
template<class DATATYPE>
DATATYPE LList<DATATYPE>::top()
{
return head->top();
}
template<class DATATYPE>
ListNode<DATATYPE>* LList<DATATYPE>::find(DATATYPE target)
{
return head->find(target);
}