aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2015-07-16 16:11:52 +0200
committerMartin Liska <marxin@gcc.gnu.org>2015-07-16 14:11:52 +0000
commitce7bc090cd410e6003f3bb3346513b1b8193eb15 (patch)
treebd3538aabec20c805dfcb30982225557bf9da3ce /gcc
parent281e728b57232be21358b49d9e356a562566e453 (diff)
downloadgcc-ce7bc090cd410e6003f3bb3346513b1b8193eb15.zip
gcc-ce7bc090cd410e6003f3bb3346513b1b8193eb15.tar.gz
gcc-ce7bc090cd410e6003f3bb3346513b1b8193eb15.tar.bz2
hash_set: add iterator and remove method.
* hash-set.h (remove): New function. (iterator): New iteration class for hash_set. From-SVN: r225885
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/hash-set.h39
2 files changed, 44 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7046378..90254ff 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-16 Martin Liska <mliska@suse.cz>
+
+ * hash-set.h (remove): New function.
+ (iterator): New iteration class for hash_set.
+
2015-07-16 Richard Sandiford <richard.sandiford@arm.com>
* genattrtab.c (make_canonical): Add a file_location parameter.
diff --git a/gcc/hash-set.h b/gcc/hash-set.h
index 2fb6cae..e85af2a 100644
--- a/gcc/hash-set.h
+++ b/gcc/hash-set.h
@@ -59,6 +59,11 @@ public:
return !Traits::is_empty (e);
}
+ void remove (const Key &k)
+ {
+ m_table.remove_elt_with_hash (k, Traits::hash (k));
+ }
+
/* Call the call back on each pair of key and value with the passed in
arg. */
@@ -74,6 +79,40 @@ public:
size_t elements () const { return m_table.elements (); }
+ class iterator
+ {
+ public:
+ explicit iterator (const typename hash_table<Traits>::iterator &iter) :
+ m_iter (iter) {}
+
+ iterator &operator++ ()
+ {
+ ++m_iter;
+ return *this;
+ }
+
+ Key
+ operator* ()
+ {
+ return *m_iter;
+ }
+
+ bool
+ operator != (const iterator &other) const
+ {
+ return m_iter != other.m_iter;
+ }
+
+ private:
+ typename hash_table<Traits>::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> friend void gt_ggc_mx (hash_set<T, U> *);