-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMap.h
60 lines (46 loc) · 1.14 KB
/
Map.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
#pragma once
#include "Vector.h"
#include "String.h"
namespace ylib {
template<class T>
class Map
{
public:
Map();
Map(const Map<T>& m);
~Map();
inline const Vector<String> getKeys() const {
return m_keys;
}
inline const Vector<T> getValues() const {
return m_values;
}
Map<T>& add(String& key, T& value);
Map<T>& add(const char *key, T& value);
T* const getValue(String& key) const;
T* const getValue(const char* key) const;
inline T* const first() const {
return m_values.get(0);
}
inline T* const last() const {
return m_values.get(size() - 1);
}
Map<T>& removeKey(String& key);
Map<T>& removeKey(const char* key);
Map<T>& clear();
inline size_t size() const {
return m_keys.size();
}
Map<T>& operator=(Map<T> const& value);
inline T* const operator[](String& key) const {
return getValue(index);
}
inline T* const operator[](const char* key) const {
return getValue(index);
}
protected:
Vector<String> m_keys;
Vector<T> m_values;
};
};
#include "Map.cpp" // Need for template