-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSortedList.h
More file actions
68 lines (54 loc) · 1.84 KB
/
SortedList.h
File metadata and controls
68 lines (54 loc) · 1.84 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
#ifndef SORTEDLIST_H
#define SORTEDLIST_H
const int MAX_ITEMS = 5;
template<class T>
class SortedList
{
public:
SortedList();
// Constructor
void MakeEmpty();
// Function: Returns the list to the empty state.
// Post: List is empty.
bool IsFull() const;
// Function: Determines whether list is full.
// Pre: List has been initialized.
// Post: Function value = (list is full)
int GetLength() const;
// Function: Determines the number of elements in list.
// Pre: List has been initialized.
// Post: Function value = number of elements in list
bool Contains(T someItem);
// Function: Determines if someItem is in the list.
// Pre: List has been initialized.
// Post: If there is an element someItem whose key matches
// item's key, then the function returns true.
// otherwise it will return false. List is unchanged.
void PutItem(T item);
// Function: Adds item to list.
// Pre: List has been initialized.
// List is not full.
// Post: item is in list if list is not full. If list is full, no change occurs.
void DeleteItem(T item);
// Function: Deletes the first element whose key matches item's key.
// Pre: ???
// Post: ???
void ResetIterator();
// Function: Initializes current position for an iteration through the list.
// Pre: List has been initialized.
// Post: Current position is prior to list.
int GetNextItem();
// Function: Gets the next element in list.
// Pre: List has been initialized and has not been changed since last call.
// Current position is defined.
// Element at current position is not last in list.
//
// Post: Current position is updated to next position.
// item is a copy of element at current position.
private:
int length;
T info[MAX_ITEMS];
int currentPos;
};
#include "SortedList.cpp"
#endif