Skip to content

Commit 7ef966c

Browse files
author
Daniel Kang
committed
no more util::idict class; util::dict now uses std::unordered_map.
1 parent 3f92979 commit 7ef966c

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

native/detail/base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <utility>
99
#include <functional>
1010
#include <map>
11+
#include <unordered_map>
1112
#include <algorithm>
1213
#include <list>
1314
#include <set>

native/detail/utility.h

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -162,52 +162,49 @@ namespace native
162162
typedef std::function<void(A...)> callback_type;
163163
};
164164

165-
template<typename C=std::less<std::string>>
166-
class dict_base
165+
class dict
167166
{
168-
typedef std::map<std::string, std::string, C> map_type;
167+
typedef std::unordered_map<std::string, std::string> map_type;
169168
typedef typename map_type::iterator iterator;
170169
typedef typename map_type::const_iterator const_iterator;
171-
typedef typename map_type::reverse_iterator reverse_iterator;
172-
typedef typename map_type::const_reverse_iterator const_reverse_iterator;
173170

174171
public:
175-
dict_base()
172+
dict()
176173
: map_()
177174
{}
178175

179-
dict_base(const map_type& map)
176+
dict(const map_type& map)
180177
: map_(map)
181178
{}
182179

183-
dict_base(const dict_base& c)
180+
dict(const dict& c)
184181
: map_(c.map_)
185182
{}
186183

187-
dict_base(dict_base&& c)
184+
dict(dict&& c)
188185
: map_(std::move(c.map_))
189186
{}
190187

191-
dict_base(std::initializer_list<typename map_type::value_type> map)
188+
dict(std::initializer_list<map_type::value_type> map)
192189
: map_(map)
193190
{}
194191

195-
virtual ~dict_base()
192+
virtual ~dict()
196193
{}
197194

198-
dict_base& operator =(const dict_base& c)
195+
dict& operator =(const dict& c)
199196
{
200197
map_ = c.map_;
201198
return *this;
202199
}
203200

204-
dict_base& operator =(dict_base&& c)
201+
dict& operator =(dict&& c)
205202
{
206203
map_ = std::move(c.map_);
207204
return *this;
208205
}
209206

210-
dict_base& operator =(std::initializer_list<typename map_type::value_type> map)
207+
dict& operator =(std::initializer_list<map_type::value_type> map)
211208
{
212209
map_ = map;
213210
return *this;
@@ -217,7 +214,7 @@ namespace native
217214
{
218215
auto it = map_.find(name);
219216
if(it != map_.end()) return it->second;
220-
else return default_value;
217+
return default_value;
221218
}
222219

223220
bool get(const std::string& name, std::string& value) const
@@ -270,21 +267,12 @@ namespace native
270267
const_iterator begin() const { return map_.begin(); }
271268
iterator end() { return map_.end(); }
272269
const_iterator end() const { return map_.end(); }
273-
reverse_iterator rbegin() { return map_.rbegin(); }
274-
const_reverse_iterator rbegin() const { return map_.rbegin(); }
275-
reverse_iterator rend() { return map_.rend(); }
276-
const_reverse_iterator rend() const { return map_.rend(); }
277270
const_iterator cbegin() const { return map_.cbegin(); }
278271
const_iterator cend() const { return map_.cend(); }
279-
const_reverse_iterator crbegin() const { return map_.crbegin(); }
280-
const_reverse_iterator crend() const { return map_.crend(); }
281272

282273
private:
283274
map_type map_;
284275
};
285-
286-
typedef dict_base<> dict;
287-
typedef dict_base<text::ci_less> idict;
288276
}
289277
}
290278

0 commit comments

Comments
 (0)