-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bag.h
51 lines (38 loc) · 986 Bytes
/
Bag.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
#pragma once
//DO NOT INCLUDE BAGITERATOR
//DO NOT CHANGE THIS PART
#define NULL_TELEM -111111;
typedef int TElem;
class BagIterator;
class Bag {
private:
//TODO - Representation
int cap_list;
int cap_pos;
int nrElemsListe;
int nrElemsPositions;
int *positions;
TElem *liste;
//DO NOT CHANGE THIS PART
friend class BagIterator;
public:
//constructor
Bag();
//adds an element to the bag
void add(TElem e);
//removes one occurence of an element from a bag
//returns true if an element was removed, false otherwise (if e was not part of the bag)
bool remove(TElem e);
//checks if an element appearch is the bag
bool search(TElem e) const;
//returns the number of occurrences for an element in the bag
int nrOccurrences(TElem e) const;
//returns the number of elements from the bag
int size() const;
//returns an iterator for this bag
BagIterator iterator() const;
//checks if the bag is empty
bool isEmpty() const;
//destructor
~Bag();
};