3
* tmap<> class template -- improved stl map<>
5
* Copyright (C) 2000-2001 by Johannes Overmann <Johannes.Overmann@gmx.de>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
# define tmap_base ttmap
31
# define tmap_base map
36
#include "texception.h"
38
// history: start 08 Jul 2000
40
// 08 Jul: removing tarray and tassocarray, this should provide tmap and tvector
42
// 15 Sep: DONT_USE_STL feature added
43
// 16 Sep: splittet tstl.h into tvector.h and tmap.h
46
template<class K, class T>
47
class tmap: public tmap_base<K,T> {
51
/// access element (read/write) (this is needed for some strange reason)
52
T& operator[](const K& key) { return tmap_base<K,T>::operator[](key); };
56
/// return whether an element with key is contained or not
57
bool contains(const K& key) const { return find(key) != tmap_base<K,T>::end(); }
58
/// access element read only (const)
59
// g++ 2.95.2 does not allow this:
60
// const T& operator[](const K& key) const { const_iterator i = find(key); if(i != end()) return i->second; else throw TNotFoundException(); } // throw(TNotFoundException)
61
const T& operator[](const K& key) const { if(contains(key)) return find(key)->second; else throw TNotFoundException(); } // throw(TNotFoundException)
65
#endif /* _ngw_tmap_h_ */