-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSAList.cpp
More file actions
38 lines (35 loc) · 1.06 KB
/
SAList.cpp
File metadata and controls
38 lines (35 loc) · 1.06 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
//sorted array-based list
//inherit from AList as a protected base class
template <typename Key, typename E>
class SAList: protected AList<KVpair<Key,E> >
{
public:
SAList(int size=defaultSize) :
AList<KVpair<Key,E> >(size) {}
~SAList() {}
//redefine insert function to keep values sorted
void insert(KVpair<Key,E>& it)
{
KVpair<Key,E> curr;
for (moveToStart(); currPos() < length(); next())
{
curr = getValue();
if (curr.key() > it.key())
break;
}
AList<KVpair<Key,E> >::insert(it);
}
//with the exception of append, all remaining methods are
//exposed from AList. Append is not available to SAlist
//class users since it has not been explicitedly exposed.
AList<KVpair<Key,E> >::clear;
AList<KVpair<Key,E> >::remove;
AList<KVpair<Key,E> >::moveToStart;
AList<KVpair<Key,E> >::moveToEnd;
AList<KVpair<Key,E> >::prev;
AList<KVpair<Key,E> >::next;
AList<KVpair<Key,E> >::length;
AList<KVpair<Key,E> >::currPos;
AList<KVpair<Key,E> >::moveToPos;
AList<KVpair<Key,E> >::getValue;
};