diff options
Diffstat (limited to 'gcc/hash-map.h')
-rw-r--r-- | gcc/hash-map.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/hash-map.h b/gcc/hash-map.h index a5816dc..f6fdc1c 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #define hash_map_h #include <new> +#include <utility> #include "hash-table.h" /* implement default behavior for traits when types allow it. */ @@ -266,6 +267,39 @@ public: size_t elements () const { return m_table.elements (); } + class iterator + { + public: + explicit iterator (const typename hash_table<hash_entry>::iterator &iter) : + m_iter (iter) {} + + iterator &operator++ () + { + ++m_iter; + return *this; + } + + std::pair<Key, Value> operator* () + { + hash_entry &e = *m_iter; + return std::pair<Key, Value> (e.m_key, e.m_value); + } + + bool + operator != (const iterator &other) const + { + return m_iter != other.m_iter; + } + + private: + typename hash_table<hash_entry>::iterator m_iter; + }; + + /* Standard iterator retrieval methods. */ + + iterator begin () const { return iterator (m_table.begin ()); } + iterator end () const { return iterator (m_table.end ()); } + private: template<typename T, typename U, typename V> friend void gt_ggc_mx (hash_map<T, U, V> *); |