-
Notifications
You must be signed in to change notification settings - Fork 2
/
Lists.h
78 lines (63 loc) · 1.42 KB
/
Lists.h
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
#ifndef __LISTS_H
#define __LISTS_H
#include <iostream>
typedef int (*CMP_FUNC) (void *, void *);
extern long MEMUSED;
template <class Items>
class ListNodes {
private:
ListNodes<Items> *theNext;
Items theItem;
public:
ListNodes(Items item, ListNodes<Items> *next);
~ListNodes();
ListNodes<Items> *next (){
return theNext;
}
void set_next (ListNodes<Items> *next){
theNext = next;
}
Items item(){
return theItem;
}
void set_item(Items item){
theItem = item;
}
};
template <class Items>
class Lists {
private:
ListNodes<Items> *theHead;
ListNodes<Items> *theLast;
int theSize;
public:
Lists();
~Lists();
void clear();
ListNodes<Items> *head (){
return theHead;
};
ListNodes<Items> *last (){
return theLast;
};
int size (){
return theSize;
};
void set_head( ListNodes<Items> *hd)
{
theHead = hd;
}
void set_last( ListNodes<Items> *lst)
{
theLast = lst;
}
void append (Items item);
void prepend(Items item);
void remove(ListNodes<Items> * prev, ListNodes<Items> * val);
void sortedDescend(Items item, CMP_FUNC cmpare);
void sortedAscend (Items item, CMP_FUNC cmpare) ;
Items find(Items item, CMP_FUNC cmpare);
int find_ascend(ListNodes<Items> *&prev,Items item, CMP_FUNC cmpare);
void insert(ListNodes<Items> *&prev, Items item);
};
#endif// __LISTS_H