-
Notifications
You must be signed in to change notification settings - Fork 0
/
List.h
67 lines (55 loc) · 1.41 KB
/
List.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
/**
* @file List.h
* @author
* @date
* @brief A List ADT
*/
#ifndef LIST_H
#define LIST_H
template <typename T>
class List
{
public:
/** @pre None.
* @post Deletes the list.
* This is a public virtual destructor with an empty definition. Though odd, it's
* commonly used in interfaces.
*/
virtual ~List(){};
/** @pre None.
* @post None.
* @return true if the list is empty, false otherwise.
*/
virtual bool isEmpty() const = 0;
/** @pre None.
* @post None.
* @return the number of elements in the list.
*/
virtual int size() const = 0;
/** @pre the value is a valid T.
* @post none.
* @return true is the value is in the list, false otherwise.
*/
virtual bool search(T value) const = 0;
/** @pre the value is a valid T.
* @post One new element added to the end of the list.
* @return none.
*/
virtual void addBack(T value) = 0;
/** @pre the value is a valid T.
* @post One new element added to the front of the list.
* @return none.
*/
virtual void addFront(T value) = 0;
/** @pre None
* @post One element is removed from the back of the list.
* @return true if the back element was removed, false if the list is empty.
*/
virtual bool removeBack() = 0;
/** @pre None
* @post One element is removed from the front of the list.
* @return true if the front element was removed, false if the list is empty.
*/
virtual bool removeFront() = 0;
};
#endif