BALL 1.5.0
Loading...
Searching...
No Matches
stringHashMap.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4// $Id: stringHashMap.h,v 1.25 2004/05/06 21:39:37 oliver Exp $
5//
6
7#ifndef BALL_DATATYPE_STRINGHASHMAP_H
8#define BALL_DATATYPE_STRINGHASHMAP_H
9
10#ifndef BALL_COMMON_H
11# include <BALL/common.h>
12#endif
13
14#ifndef BALL_COMMON_HASH_H
15# include <BALL/COMMON/hash.h>
16#endif
17
18#ifndef BALL_CONCEPT_VISITOR_H
19# include <BALL/CONCEPT/visitor.h>
20#endif
21
22#ifndef BALL_CONCEPT_PROCESSOR_H
24#endif
25
26#ifndef BALL_DATATYPE_HASHMAP_H
28#endif
29
30#include <algorithm>
31
32namespace BALL
33{
34
35
39 template <typename Value>
41 : public HashMap<String, Value>
42 {
43 public:
44
46
47
50
51
53 typedef typename HashMap<String, Value>::Iterator Iterator;
54
57 typedef typename HashMap<String, Value>::ConstIterator ConstIterator;
58
61 typedef typename HashMap<String, Value>::ValueType ValueType;
63
66
71 : HashMap<String, Value>()
72 {
73 }
74
80 : HashMap<String, Value>(map)
81 {
82 }
83
88 {
89 }
90
94 void destroy()
95 {
97 }
98
100
103
108 void set(const StringHashMap& hash_map)
109 {
111
112 ConstIterator it = hash_map.begin();
113 for ( ; it != hash_map.end(); ++it)
114 {
115 insert(*it);
116 }
117 }
118
121 {
122 set(hash_map);
123 return *this;
124 }
125
127 void get(StringHashMap& hash_map) const
128 {
129 hash_map.set(*this);
130 }
131
133 void swap(StringHashMap& hash_map)
134 {
135 std::swap(*this, hash_map);
136 }
137
139
142
145 std::pair<Iterator, bool> insert(const ValueType& obj)
146 {
148 }
149
154 ::std::pair<Iterator, bool> insert(const String& key, const Value& value)
155 {
156 return HashMap<String, Value>::insert(::std::pair<String, Value>(key, value));
157 }
158
159
164 bool remove(const String& key)
165 {
166 // search the key
168 if (it == HashMap<String, Value>::end())
169 {
170 // we didn't find it..
171 return false;
172 }
173
174 // found it: delete it
176
177 return true;
178 }
179
182 Size getSize() const
183 {
185 }
186
188
191
194 bool operator == (const StringHashMap<Value>& hash_map) const
195 {
197 }
198
201 bool operator != (const StringHashMap<Value>& hash_map) const
202 {
203 return !(HashMap<String, Value>::operator == (hash_map));
204 }
205
208 bool has(const String& key) const
209 {
211 }
212
216 bool isEmpty() const
217 {
218 return (HashMap<String, Value>::size() == 0);
219 }
221
224
230 {
231 visitor.visit(*this);
232 }
234
235 };
236
237// required for visual studio
238#ifdef BALL_COMPILER_MSVC
239template class BALL_EXPORT StringHashMap<String>;
240#endif
241
242}// namespace BALL
243
244#endif // BALL_DATATYPE_HASHMAP_H
#define BALL_CREATE(name)
Definition create.h:62
HashMap class based on the STL map (containing serveral convenience functions)
Definition hashMap.h:74
Size size() const
Definition hashMap.h:122
bool operator==(const HashMap< Key, T > &rhs) const
Equality operator. Check whether two two hashmaps contain the same elements. O(n) runtime.
Definition hashMap.h:144
StringHashMap(const StringHashMap &map)
HashMap< String, Value >::Iterator Iterator
HashMap< String, Value >::ConstIterator ConstIterator
bool remove(const String &key)
const StringHashMap & operator=(const StringHashMap &hash_map)
Assign a hash map from another.
void host(Visitor< StringHashMap< Value > > &visitor)
void set(const StringHashMap &hash_map)
bool has(const String &key) const
::std::pair< Iterator, bool > insert(const String &key, const Value &value)
void get(StringHashMap &hash_map) const
Assigns the content of a hash map to another.
HashMap< String, Value >::ValueType ValueType
bool operator!=(const StringHashMap< Value > &hash_map) const
void swap(StringHashMap &hash_map)
Swaps the contents of two hash maps.
std::pair< Iterator, bool > insert(const ValueType &obj)
bool operator==(const StringHashMap< Value > &hash_map) const
#define BALL_EXPORT