diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-14 10:43:30 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-14 10:43:30 +0000 |
commit | 89149bf77ddbe9a6b7bc772abb0ee066ecfb809e (patch) | |
tree | 031057077c5637a156bf6765bc067d615925071e /libstdc++-v3 | |
parent | 712788fe886e3a6b96045949a77d524b422bbb23 (diff) | |
download | gcc-89149bf77ddbe9a6b7bc772abb0ee066ecfb809e.tar.gz |
2005-10-14 Paolo Carlini <pcarlini@suse.de>
* include/tr1/hashtable (hashtable::m_erase): Rename to erase_node.
(hashtable::erase(iterator), erase(const_iterator)): Adjust.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105401 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/hashtable | 76 |
2 files changed, 44 insertions, 37 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d4a25a179aa..257e7289840 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2005-10-14 Paolo Carlini <pcarlini@suse.de> + + * include/tr1/hashtable (hashtable::m_erase): Rename to erase_node. + (hashtable::erase(iterator), erase(const_iterator)): Adjust. + 2005-10-13 Richard Earnshaw <richard.earnsahw@arm.com> PR libstdc++/23926 diff --git a/libstdc++-v3/include/tr1/hashtable b/libstdc++-v3/include/tr1/hashtable index 36e33b0f418..0add0e3a966 100644 --- a/libstdc++-v3/include/tr1/hashtable +++ b/libstdc++-v3/include/tr1/hashtable @@ -329,7 +329,8 @@ namespace Internal { hashtable_iterator tmp(*this); this->incr(); - return tmp; } + return tmp; + } }; template<typename Value, bool constant_iterators, bool cache> @@ -374,7 +375,8 @@ namespace Internal { hashtable_const_iterator tmp(*this); this->incr(); - return tmp; } + return tmp; + } }; } // namespace Internal @@ -1169,6 +1171,9 @@ namespace tr1 iterator insert(const value_type&, std::tr1::false_type); + void + erase_node(node*, node**); + public: // Insert and erase Insert_Return_Type insert(const value_type& v) @@ -1191,25 +1196,21 @@ namespace tr1 iterator erase(iterator); - + const_iterator erase(const_iterator); - + size_type erase(const key_type&); iterator erase(iterator, iterator); - + const_iterator erase(const_iterator, const_iterator); void clear(); - - private: - // For erase(iterator) and erase(const_iterator). - void m_erase(node*, node**); public: // Set number of buckets to be apropriate for container of n element. @@ -1673,6 +1674,33 @@ namespace tr1 return iterator(new_node, m_buckets + n); } + // For erase(iterator) and erase(const_iterator). + template<typename K, typename V, + typename A, typename Ex, typename Eq, + typename H1, typename H2, typename H, typename RP, + bool c, bool ci, bool u> + void + hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>:: + erase_node(node* p, node** b) + { + node* cur = *b; + if (cur == p) + *b = cur->m_next; + else + { + node* next = cur->m_next; + while (next != p) + { + cur = next; + next = cur->m_next; + } + cur->m_next = next->m_next; + } + + m_deallocate_node (p); + --m_element_count; + } + template<typename K, typename V, typename A, typename Ex, typename Eq, typename H1, typename H2, typename H, typename RP, @@ -1702,7 +1730,7 @@ namespace tr1 { iterator result = i; ++result; - m_erase(i.m_cur_node, i.m_cur_bucket); + erase_node(i.m_cur_node, i.m_cur_bucket); return result; } @@ -1716,7 +1744,7 @@ namespace tr1 { const_iterator result = i; ++result; - m_erase(i.m_cur_node, i.m_cur_bucket); + erase_node(i.m_cur_node, i.m_cur_bucket); return result; } @@ -1825,32 +1853,6 @@ namespace tr1 __throw_exception_again; } } - - template<typename K, typename V, - typename A, typename Ex, typename Eq, - typename H1, typename H2, typename H, typename RP, - bool c, bool ci, bool u> - void - hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>:: - m_erase(node* p, node** b) - { - node* cur = *b; - if (cur == p) - *b = cur->m_next; - else - { - node* next = cur->m_next; - while (next != p) - { - cur = next; - next = cur->m_next; - } - cur->m_next = next->m_next; - } - - m_deallocate_node (p); - --m_element_count; - } } } // Namespace std::tr1 |