#include <stl_hashtable.h>
Inheritance diagram for hashtable:


|
|||||
|
|||||
|
Definition at line 175 of file stl_hashtable.h. |
|
|||||
|
Definition at line 177 of file stl_hashtable.h. |
|
|||||
|
Definition at line 173 of file stl_hashtable.h. |
|
|||||
|
Definition at line 169 of file stl_hashtable.h. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::hash_funct. |
|
|||||
|
|||||
|
Definition at line 170 of file stl_hashtable.h. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::key_eq. |
|
|||||
|
|||||
|
Definition at line 187 of file stl_hashtable.h. |
|
|||||
|
Definition at line 188 of file stl_hashtable.h. |
|
|||||
|
Definition at line 174 of file stl_hashtable.h. |
|
|||||
|
Definition at line 176 of file stl_hashtable.h. |
|
|||||
|
|||||
|
||||||||||||||||||||||||
|
Definition at line 208 of file stl_hashtable.h.
00212 : hash(hf), equals(eql), get_key(ext), num_elements(0) 00213 { 00214 initialize_buckets(n); 00215 } |
|
||||||||||||||||||||
|
Definition at line 217 of file stl_hashtable.h.
00220 : hash(hf), equals(eql), get_key(ExtractKey()), num_elements(0) 00221 { 00222 initialize_buckets(n); 00223 } |
|
||||||||||
|
Definition at line 225 of file stl_hashtable.h.
|
|
|||||||||
|
Definition at line 243 of file stl_hashtable.h.
00243 { clear(); }
|
|
|||||||||
|
Definition at line 268 of file stl_hashtable.h.
|
|
|||||||||
|
Definition at line 258 of file stl_hashtable.h.
|
|
||||||||||||||||
|
Definition at line 472 of file stl_hashtable.h.
00473 {
00474 return bkt_num_key(get_key(obj), n);
00475 }
|
|
||||||||||
|
Definition at line 462 of file stl_hashtable.h. Referenced by erase, find_or_insert, insert_equal_noresize, insert_unique_noresize, __hashtable_const_iterator::operator++, __hashtable_iterator::operator++, and resize.
00463 {
00464 return bkt_num_key(get_key(obj));
00465 }
|
|
||||||||||||||||
|
Definition at line 467 of file stl_hashtable.h.
00468 {
00469 return hash(key) % n;
00470 }
|
|
||||||||||
|
Definition at line 457 of file stl_hashtable.h. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::bkt_num, hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::bkt_num_key, hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::count, equal_range, erase, and hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::find.
00458 {
00459 return bkt_num_key(key, buckets.size());
00460 }
|
|
|||||||||
|
Definition at line 283 of file stl_hashtable.h.
|
|
|||||||||
|
Definition at line 904 of file stl_hashtable.h. References delete_node, __hashtable_node::next, num_elements, vector::size, and size_type. Referenced by copy_from, hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::operator=, and hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::~hashtable.
00905 {
00906 for (size_type i = 0; i < buckets.size(); ++i) {
00907 node* cur = buckets[i];
00908 while (cur != 0) {
00909 node* next = cur->next;
00910 delete_node(cur);
00911 cur = next;
00912 }
00913 buckets[i] = 0;
00914 }
00915 num_elements = 0;
00916 }
|
|
||||||||||
|
||||||||||
|
Definition at line 422 of file stl_hashtable.h.
|
|
||||||||||
|
Definition at line 488 of file stl_hashtable.h. Referenced by clear, erase, erase_bucket, and resize.
00489 {
00490 destroy(&n->val);
00491 node_allocator::deallocate(n);
00492 }
|
|
||||||||||
|
Definition at line 288 of file stl_hashtable.h.
|
|
|||||||||
|
Definition at line 247 of file stl_hashtable.h.
00247 { return size() == 0; }
|
|
|||||||||
|
Definition at line 276 of file stl_hashtable.h.
00276 { return const_iterator(0, this); }
|
|
|||||||||
|
Definition at line 266 of file stl_hashtable.h. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::begin, and equal_range.
00266 { return iterator(0, this); }
|
|
||||||||||
|
Definition at line 709 of file stl_hashtable.h. References bkt_num_key, const_iterator, end, equals, get_key, __hashtable_node::next, size_type, and __hashtable_node::val.
00710 {
00711 typedef pair<const_iterator, const_iterator> pii;
00712 const size_type n = bkt_num_key(key);
00713
00714 for (const node* first = buckets[n] ; first; first = first->next) {
00715 if (equals(get_key(first->val), key)) {
00716 for (const node* cur = first->next; cur; cur = cur->next)
00717 if (!equals(get_key(cur->val), key))
00718 return pii(const_iterator(first, this),
00719 const_iterator(cur, this));
00720 for (size_type m = n + 1; m < buckets.size(); ++m)
00721 if (buckets[m])
00722 return pii(const_iterator(first, this),
00723 const_iterator(buckets[m], this));
00724 return pii(const_iterator(first, this), end());
00725 }
00726 }
00727 return pii(end(), end());
00728 }
|
|
||||||||||
|
Definition at line 686 of file stl_hashtable.h. References bkt_num_key, end, equals, get_key, iterator, __hashtable_node::next, size_type, and __hashtable_node::val.
00687 {
00688 typedef pair<iterator, iterator> pii;
00689 const size_type n = bkt_num_key(key);
00690
00691 for (node* first = buckets[n]; first; first = first->next) {
00692 if (equals(get_key(first->val), key)) {
00693 for (node* cur = first->next; cur; cur = cur->next)
00694 if (!equals(get_key(cur->val), key))
00695 return pii(iterator(first, this), iterator(cur, this));
00696 for (size_type m = n + 1; m < buckets.size(); ++m)
00697 if (buckets[m])
00698 return pii(iterator(first, this),
00699 iterator(buckets[m], this));
00700 return pii(iterator(first, this), end());
00701 }
00702 }
00703 return pii(end(), end());
00704 }
|
|
||||||||||||||||
|
Definition at line 815 of file stl_hashtable.h. References __hashtable_const_iterator::cur, erase, __hashtable_const_iterator::ht, and iterator.
|
|
||||||||||
|
Definition at line 826 of file stl_hashtable.h. References __hashtable_const_iterator::cur, erase, __hashtable_const_iterator::ht, and iterator.
|
|
||||||||||||||||
|
Definition at line 795 of file stl_hashtable.h. References bkt_num, __hashtable_iterator::cur, erase_bucket, vector::size, size_type, and __hashtable_node::val.
00796 {
00797 size_type f_bucket = first.cur ? bkt_num(first.cur->val) : buckets.size();
00798 size_type l_bucket = last.cur ? bkt_num(last.cur->val) : buckets.size();
00799
00800 if (first.cur == last.cur)
00801 return;
00802 else if (f_bucket == l_bucket)
00803 erase_bucket(f_bucket, first.cur, last.cur);
00804 else {
00805 erase_bucket(f_bucket, first.cur, 0);
00806 for (size_type n = f_bucket + 1; n < l_bucket; ++n)
00807 erase_bucket(n, 0);
00808 if (l_bucket != buckets.size())
00809 erase_bucket(l_bucket, last.cur);
00810 }
00811 }
|
|
||||||||||
|
Definition at line 765 of file stl_hashtable.h. References bkt_num, __hashtable_iterator::cur, delete_node, __hashtable_node::next, num_elements, size_type, and __hashtable_node::val.
00766 {
00767 if (node* const p = it.cur) {
00768 const size_type n = bkt_num(p->val);
00769 node* cur = buckets[n];
00770
00771 if (cur == p) {
00772 buckets[n] = cur->next;
00773 delete_node(cur);
00774 --num_elements;
00775 }
00776 else {
00777 node* next = cur->next;
00778 while (next) {
00779 if (next == p) {
00780 cur->next = next->next;
00781 delete_node(next);
00782 --num_elements;
00783 break;
00784 }
00785 else {
00786 cur = next;
00787 next = cur->next;
00788 }
00789 }
00790 }
00791 }
00792 }
|
|
||||||||||
|
Definition at line 732 of file stl_hashtable.h. References bkt_num_key, delete_node, equals, get_key, __hashtable_node::next, num_elements, size_type, and __hashtable_node::val. Referenced by erase.
00733 {
00734 const size_type n = bkt_num_key(key);
00735 node* first = buckets[n];
00736 size_type erased = 0;
00737
00738 if (first) {
00739 node* cur = first;
00740 node* next = cur->next;
00741 while (next) {
00742 if (equals(get_key(next->val), key)) {
00743 cur->next = next->next;
00744 delete_node(next);
00745 next = cur->next;
00746 ++erased;
00747 --num_elements;
00748 }
00749 else {
00750 cur = next;
00751 next = cur->next;
00752 }
00753 }
00754 if (equals(get_key(first->val), key)) {
00755 buckets[n] = first->next;
00756 delete_node(first);
00757 ++erased;
00758 --num_elements;
00759 }
00760 }
00761 return erased;
00762 }
|
|
||||||||||||||||
|
Definition at line 891 of file stl_hashtable.h. References delete_node, __hashtable_node::next, and num_elements.
00892 {
00893 node* cur = buckets[n];
00894 while (cur != last) {
00895 node* next = cur->next;
00896 delete_node(cur);
00897 cur = next;
00898 buckets[n] = cur;
00899 --num_elements;
00900 }
00901 }
|
|
||||||||||||||||||||
|
Definition at line 870 of file stl_hashtable.h. References delete_node, __hashtable_node::next, and num_elements. Referenced by erase.
00872 {
00873 node* cur = buckets[n];
00874 if (cur == first)
00875 erase_bucket(n, last);
00876 else {
00877 node* next;
00878 for (next = cur->next; next != first; cur = next, next = cur->next)
00879 ;
00880 while (next) {
00881 cur->next = next->next;
00882 delete_node(next);
00883 next = cur->next;
00884 --num_elements;
00885 }
00886 }
00887 }
|
|
||||||||||
|
Definition at line 411 of file stl_hashtable.h.
00412 {
00413 size_type n = bkt_num_key(key);
00414 const node* first;
00415 for ( first = buckets[n];
00416 first && !equals(get_key(first->val), key);
00417 first = first->next)
00418 {}
00419 return const_iterator(first, this);
00420 }
|
|
||||||||||
|
Definition at line 400 of file stl_hashtable.h.
|
|
||||||||||
|
Definition at line 665 of file stl_hashtable.h. References bkt_num, equals, get_key, new_node, __hashtable_node::next, num_elements, resize, size_type, __hashtable_node::val, and value_type.
00666 {
00667 resize(num_elements + 1);
00668
00669 size_type n = bkt_num(obj);
00670 node* first = buckets[n];
00671
00672 for (node* cur = first; cur; cur = cur->next)
00673 if (equals(get_key(cur->val), get_key(obj)))
00674 return cur->val;
00675
00676 node* tmp = new_node(obj);
00677 tmp->next = first;
00678 buckets[n] = tmp;
00679 ++num_elements;
00680 return tmp->val;
00681 }
|
|
|||||||||
|
Definition at line 179 of file stl_hashtable.h.
00179 { return hash; }
|
|
||||||||||
|
Definition at line 449 of file stl_hashtable.h. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::hashtable.
|
|
||||||||||||||||
|
Definition at line 388 of file stl_hashtable.h.
00389 {
00390 size_type n = 0;
00391 distance(f, l, n);
00392 resize(num_elements + n);
00393 for ( ; n > 0; --n, ++f)
00394 insert_equal_noresize(*f);
00395 }
|
|
||||||||||||||||
|
Definition at line 371 of file stl_hashtable.h.
00372 {
00373 size_type n = l - f;
00374 resize(num_elements + n);
00375 for ( ; n > 0; --n, ++f)
00376 insert_equal_noresize(*f);
00377 }
|
|
||||||||||
|
Definition at line 302 of file stl_hashtable.h.
00303 {
00304 resize(num_elements + 1);
00305 return insert_equal_noresize(obj);
00306 }
|
|
||||||||||
|
Definition at line 642 of file stl_hashtable.h. References bkt_num, equals, get_key, iterator, new_node, __hashtable_node::next, num_elements, size_type, __hashtable_node::val, and value_type. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::insert_equal.
00643 {
00644 const size_type n = bkt_num(obj);
00645 node* first = buckets[n];
00646
00647 for (node* cur = first; cur; cur = cur->next)
00648 if (equals(get_key(cur->val), get_key(obj))) {
00649 node* tmp = new_node(obj);
00650 tmp->next = cur->next;
00651 cur->next = tmp;
00652 ++num_elements;
00653 return iterator(tmp, this);
00654 }
00655
00656 node* tmp = new_node(obj);
00657 tmp->next = first;
00658 buckets[n] = tmp;
00659 ++num_elements;
00660 return iterator(tmp, this);
00661 }
|
|
||||||||||||||||
|
Definition at line 379 of file stl_hashtable.h.
00380 {
00381 size_type n = 0;
00382 distance(f, l, n);
00383 resize(num_elements + n);
00384 for ( ; n > 0; --n, ++f)
00385 insert_unique_noresize(*f);
00386 }
|
|
||||||||||||||||
|
Definition at line 363 of file stl_hashtable.h.
00364 {
00365 size_type n = l - f;
00366 resize(num_elements + n);
00367 for ( ; n > 0; --n, ++f)
00368 insert_unique_noresize(*f);
00369 }
|
|
||||||||||
|
Definition at line 296 of file stl_hashtable.h.
00297 {
00298 resize(num_elements + 1);
00299 return insert_unique_noresize(obj);
00300 }
|
|
||||||||||
|
Definition at line 624 of file stl_hashtable.h. References bkt_num, equals, get_key, iterator, new_node, __hashtable_node::next, num_elements, size_type, __hashtable_node::val, and value_type. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::insert_unique.
00625 {
00626 const size_type n = bkt_num(obj);
00627 node* first = buckets[n];
00628
00629 for (node* cur = first; cur; cur = cur->next)
00630 if (equals(get_key(cur->val), get_key(obj)))
00631 return pair<iterator, bool>(iterator(cur, this), false);
00632
00633 node* tmp = new_node(obj);
00634 tmp->next = first;
00635 buckets[n] = tmp;
00636 ++num_elements;
00637 return pair<iterator, bool>(iterator(tmp, this), true);
00638 }
|
|
|||||||||
|
Definition at line 180 of file stl_hashtable.h.
00180 { return equals; }
|
|
|||||||||
|
Definition at line 285 of file stl_hashtable.h.
00286 { return __stl_prime_list[__stl_num_primes - 1]; }
|
|
|||||||||
|
Definition at line 246 of file stl_hashtable.h.
00246 { return size_type(-1); }
|
|
||||||||||
|
Definition at line 477 of file stl_hashtable.h. Referenced by copy_from, find_or_insert, insert_equal_noresize, and insert_unique_noresize.
00478 {
00479 node* n = node_allocator::allocate();
00480 n->next = 0;
00481 __STL_TRY {
00482 construct(&n->val, obj);
00483 return n;
00484 }
00485 __STL_UNWIND(node_allocator::deallocate(n));
00486 }
|
|
||||||||||
|
Definition at line 447 of file stl_hashtable.h. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::initialize_buckets, and resize.
00447 { return __stl_next_prime(n); }
|
|
||||||||||
|
Definition at line 231 of file stl_hashtable.h.
|
|
||||||||||
|
Definition at line 833 of file stl_hashtable.h. References __STL_TRY, bkt_num, delete_node, __hashtable_node::next, next_size, vector::size, size_type, vector::swap, and __hashtable_node::val. Referenced by find_or_insert, hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::insert_equal, and hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::insert_unique.
00834 {
00835 const size_type old_n = buckets.size();
00836 if (num_elements_hint > old_n) {
00837 const size_type n = next_size(num_elements_hint);
00838 if (n > old_n) {
00839 vector<node*, A> tmp(n, (node*) 0);
00840 __STL_TRY {
00841 for (size_type bucket = 0; bucket < old_n; ++bucket) {
00842 node* first = buckets[bucket];
00843 while (first) {
00844 size_type new_bucket = bkt_num(first->val, n);
00845 buckets[bucket] = first->next;
00846 first->next = tmp[new_bucket];
00847 tmp[new_bucket] = first;
00848 first = buckets[bucket];
00849 }
00850 }
00851 buckets.swap(tmp);
00852 }
00853 # ifdef __STL_USE_EXCEPTIONS
00854 catch(...) {
00855 for (size_type bucket = 0; bucket < tmp.size(); ++bucket) {
00856 while (tmp[bucket]) {
00857 node* next = tmp[bucket]->next;
00858 delete_node(tmp[bucket]);
00859 tmp[bucket] = next;
00860 }
00861 }
00862 throw;
00863 }
00864 # endif /* __STL_USE_EXCEPTIONS */
00865 }
00866 }
00867 }
|
|
|||||||||
|
Definition at line 245 of file stl_hashtable.h. Referenced by hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::empty.
00245 { return num_elements; }
|
|
||||||||||
|
Definition at line 249 of file stl_hashtable.h.
00250 {
00251 __STD::swap(hash, ht.hash);
00252 __STD::swap(equals, ht.equals);
00253 __STD::swap(get_key, ht.get_key);
00254 buckets.swap(ht.buckets);
00255 __STD::swap(num_elements, ht.num_elements);
00256 }
|
|
|||||
|
Definition at line 204 of file stl_hashtable.h. |
|
|||||
|
Definition at line 202 of file stl_hashtable.h. |
|
||||||||||||||||
|
|
|
|||||
|
Definition at line 190 of file stl_hashtable.h. Referenced by copy_from, __hashtable_const_iterator::operator++, __hashtable_iterator::operator++, operator==, and hashtable< Value, Value, HashFcn, identity< Value >, EqualKey, Alloc >::swap. |
|
|||||
|
|||||
|
|||||
|
|||||
| Documentation generated on Thu May 2 15:03:31 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |