-
Notifications
You must be signed in to change notification settings - Fork 0
/
set.hpp
54 lines (47 loc) · 1.21 KB
/
set.hpp
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
#ifndef _SET_H_
#define _SET_H_
/*
* Abstract base class of the set
* A set has the following Properties:
* - Order doesn't matter
* - Duplicates are not allowed
*/
class Set {
protected:
const int domainHigh; //ignore this
const int domainLow; //ignore this
const int N; //just pay attention to this
public:
//create a set. We will only use domain High. We will not use domain low
Set(int domainHigh, int domainLow = 0)
:domainHigh(domainHigh), domainLow(domainLow), N(domainHigh - domainLow)
{}
/*
* insert an integer into the set
* remember Sets do not allow duplicates
* if the insert is successfull (the element is not already inserted), return true
* else return false
*/
virtual bool insert(int) = 0;
/*
* remove an integer from the set
* return true if anything was removed.
* return false if the element was non existant (had not been inserted)
*/
virtual bool remove(int) = 0;
/*
* lookup to see if an element exists in the set
* return true if the element has been inserted
* else return false
*/
virtual bool lookup(int) = 0;
/*
* clear out all emenents in the set
*/
virtual void clear() = 0;
/*
* return the number of elements in the set
*/
virtual int size() = 0;
};
#endif