From: marxin Date: Thu, 16 Jul 2015 14:11:52 +0000 (+0000) Subject: hash_set: add iterator and remove method. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a3c990e4aed6592f120821a082ef9b365b17f48d;p=thirdparty%2Fgcc.git hash_set: add iterator and remove method. * hash-set.h (remove): New function. (iterator): New iteration class for hash_set. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225885 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7046378a4797..90254ffb0a80 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-07-16 Martin Liska + + * hash-set.h (remove): New function. + (iterator): New iteration class for hash_set. + 2015-07-16 Richard Sandiford * genattrtab.c (make_canonical): Add a file_location parameter. diff --git a/gcc/hash-set.h b/gcc/hash-set.h index 2fb6cae7362a..e85af2a17452 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::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::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 friend void gt_ggc_mx (hash_set *);