-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.h
More file actions
58 lines (39 loc) · 1.35 KB
/
Copy pathMap.h
File metadata and controls
58 lines (39 loc) · 1.35 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
#pragma once
#include <utility>
typedef int TKey;
typedef int TValue;
typedef std::pair<TKey, TValue> TElem;
#define NULL_TVALUE -111111
#define NULL_TELEM pair<TKey, TValue>(-111111, -111111)
class MapIterator;
class Map {
//DO NOT CHANGE THIS PART
friend class MapIterator;
private:
//TODO - Representation
int cap;
int nrElems;
std::pair<TKey,TValue>* elements;
public:
// implicit constructor
Map();
//copyconstructor
Map(const Map& original);
Map filter(TKey index1, TKey index2);
// adds a pair (key,value) to the map
//if the key already exists in the map, then the value associated to the key is replaced by the new value and the old value is returned
//if the key does not exist, a new pair is added and the value null is returned
TValue add(TKey c, TValue v);
//searches for the key and returns the value associated with the key if the map contains the key or null: NULL_TVALUE otherwise
TValue search(TKey c) const;
//removes a key from the map and returns the value associated with the key if the key existed ot null: NULL_TVALUE otherwise
TValue remove(TKey c);
//returns the number of pairs (key,value) from the map
int size() const;
//checks whether the map is empty or not
bool isEmpty() const;
//returns an iterator for the map
MapIterator iterator() const;
// destructor
~Map();
};