Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Creator - MatthewGolder
- #ifndef MAP_H
- #define MAP_H
- #include "Vector.h"
- #define FOR_EACH_MAP(map, count, iteratorName) for(unsigned int iteratorName = 0; iteratorName < count; iteratorName++)
- template<typename K, typename V>
- class MapEntry
- {
- public:
- MapEntry<K, V>(void);
- MapEntry<K, V>(const K& key, const V& value);
- bool operator== (const MapEntry<K,V>& rhs)const{return _key == rhs._key && _value == rhs._value;}
- bool operator!= (const MapEntry<K,V>& rhs)const{return !(*this == rhs);}
- K& First(void);
- const K& First(void)const;
- void First(const K& key);
- V& Second(void);
- const V& Second(void)const;
- void Second(const V& value);
- private:
- K _key;
- V _value;
- };
- template<typename K, typename V>
- class Map
- {
- public:
- typedef MapEntry<K, V> MapElements;
- Map(void);
- ~Map(void);
- MapEntry<K, V>& operator[](unsigned int i);
- const MapEntry<K, V>& operator[](unsigned int i)const;
- MapEntry<K, V>& Element(unsigned int i);
- const MapEntry<K, V>& Element(unsigned int i)const;
- void Insert(const MapEntry<K, V> entry);
- void Insert(const K& key, const V& value);
- int FindKey(const K& key)const;
- bool Contains (const K& key)const;
- bool Compare (const MapElements& lhs, const MapElements& rhs)const;
- bool CompareKey (const K& lhs, const K& rhs)const;
- bool CompareValue(const V& lhs, const V& rhs)const;
- void Remove(unsigned int elem);
- void Remove(const K& key);
- void Clear(void);
- unsigned int Count (void)const{return _mapTable.Count();}
- unsigned int Capacity(void)const{return _mapTable.Capacity();}
- private:
- Vector<MapElements> _mapTable;
- };
- #include "Map.inl"
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement