summaryrefslogtreecommitdiffstats
path: root/base/id_map.h
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-11 13:51:15 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-11 13:51:15 +0000
commit663fe3c5c9327b3b604fe7f2c7fd3f4d5cccc4e4 (patch)
tree442c8f0512788211e78a0a26f0913f507d066e4e /base/id_map.h
parent8952642e62dd4ca8945115b3d9ae46458c62ea22 (diff)
downloadchromium_src-663fe3c5c9327b3b604fe7f2c7fd3f4d5cccc4e4.zip
chromium_src-663fe3c5c9327b3b604fe7f2c7fd3f4d5cccc4e4.tar.gz
chromium_src-663fe3c5c9327b3b604fe7f2c7fd3f4d5cccc4e4.tar.bz2
Define a private IDMap::iterator, and use our own iterator / const_iterator.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/id_map.h')
-rw-r--r--base/id_map.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/base/id_map.h b/base/id_map.h
index 140d025..3c508ac 100644
--- a/base/id_map.h
+++ b/base/id_map.h
@@ -46,17 +46,19 @@ template<class T>
class IDMap {
private:
typedef base::hash_map<int32, T*> HashTable;
+ typedef typename HashTable::iterator iterator;
public:
+ // support const iterators over the items
+ // Note, use iterator->first to get the ID, iterator->second to get the T*
+ typedef typename HashTable::const_iterator const_iterator;
+
IDMap() : next_id_(1) {
}
IDMap(const IDMap& other) : next_id_(other.next_id_),
data_(other.data_) {
}
- // support const iterators over the items
- // Note, use iterator->first to get the ID, iterator->second to get the T*
- typedef typename HashTable::const_iterator const_iterator;
const_iterator begin() const {
return data_.begin();
}
@@ -83,7 +85,7 @@ class IDMap {
}
void Remove(int32 id) {
- typename HashTable::iterator i = data_.find(id);
+ iterator i = data_.find(id);
if (i == data_.end()) {
NOTREACHED() << "Attempting to remove an item not in the list";
return;
@@ -96,7 +98,7 @@ class IDMap {
}
T* Lookup(int32 id) const {
- typename HashTable::const_iterator i = data_.find(id);
+ const_iterator i = data_.find(id);
if (i == data_.end())
return NULL;
return i->second;