15.12.2011 - version 0.1.1
This commit is contained in:
@@ -279,14 +279,14 @@ inline bool operator <(const PIPair<Type0, Type1> & value0, const PIPair<Type0,
|
||||
|
||||
|
||||
template<typename Type, typename Key = int>
|
||||
class PIHash: public PISet<PIPair<Key, Type> > {
|
||||
typedef PIHash<Type, Key> _CHash;
|
||||
class PIMap: public PISet<PIPair<Key, Type> > {
|
||||
typedef PIMap<Type, Key> _CMap;
|
||||
typedef PISet<PIPair<Key, Type> > _CSet;
|
||||
public:
|
||||
PIHash() {;}
|
||||
PIHash(const Type & value, const Key & key) {insert(value, key);}
|
||||
_CHash & insert(const Type & value, const Key & key) {_CSet::insert(PIPair<Key, Type>(key, value)); return *this;}
|
||||
Type value(Key key) const {for (typename _CHash::iterator i = _CHash::begin(); i != _CHash::end(); i++) if ((*i).first == key) return (*i).second; return Type();}
|
||||
PIMap() {;}
|
||||
PIMap(const Type & value, const Key & key) {insert(value, key);}
|
||||
_CMap & insert(const Type & value, const Key & key) {_CSet::insert(PIPair<Key, Type>(key, value)); return *this;}
|
||||
Type value(Key key) const {for (typename _CMap::iterator i = _CMap::begin(); i != _CMap::end(); i++) if ((*i).first == key) return (*i).second; return Type();}
|
||||
Type operator[](Key key) const {return value(key);}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user