comparison libstdc++-v3/include/tr1/hashtable.h @ 155:da32f4b04d38

fix __code name conflict
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 17:51:46 +0900
parents 1830386684a0
children
comparison
equal deleted inserted replaced
151:2eca1fb48fa2 155:da32f4b04d38
701 __chc, __cit, __uk>::iterator 701 __chc, __cit, __uk>::iterator
702 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 702 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
703 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 703 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
704 find(const key_type& __k) 704 find(const key_type& __k)
705 { 705 {
706 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 706 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
707 std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 707 std::size_t __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
708 _Node* __p = _M_find_node(_M_buckets[__n], __k, __code); 708 _Node* __p = _M_find_node(_M_buckets[__n], __k, __code0);
709 return __p ? iterator(__p, _M_buckets + __n) : this->end(); 709 return __p ? iterator(__p, _M_buckets + __n) : this->end();
710 } 710 }
711 711
712 template<typename _Key, typename _Value, 712 template<typename _Key, typename _Value,
713 typename _Allocator, typename _ExtractKey, typename _Equal, 713 typename _Allocator, typename _ExtractKey, typename _Equal,
718 __chc, __cit, __uk>::const_iterator 718 __chc, __cit, __uk>::const_iterator
719 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 719 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
720 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 720 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
721 find(const key_type& __k) const 721 find(const key_type& __k) const
722 { 722 {
723 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 723 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
724 std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 724 std::size_t __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
725 _Node* __p = _M_find_node(_M_buckets[__n], __k, __code); 725 _Node* __p = _M_find_node(_M_buckets[__n], __k, __code0);
726 return __p ? const_iterator(__p, _M_buckets + __n) : this->end(); 726 return __p ? const_iterator(__p, _M_buckets + __n) : this->end();
727 } 727 }
728 728
729 template<typename _Key, typename _Value, 729 template<typename _Key, typename _Value,
730 typename _Allocator, typename _ExtractKey, typename _Equal, 730 typename _Allocator, typename _ExtractKey, typename _Equal,
735 __chc, __cit, __uk>::size_type 735 __chc, __cit, __uk>::size_type
736 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 736 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
737 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 737 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
738 count(const key_type& __k) const 738 count(const key_type& __k) const
739 { 739 {
740 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 740 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
741 std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 741 std::size_t __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
742 std::size_t __result = 0; 742 std::size_t __result = 0;
743 for (_Node* __p = _M_buckets[__n]; __p; __p = __p->_M_next) 743 for (_Node* __p = _M_buckets[__n]; __p; __p = __p->_M_next)
744 if (this->_M_compare(__k, __code, __p)) 744 if (this->_M_compare(__k, __code0, __p))
745 ++__result; 745 ++__result;
746 return __result; 746 return __result;
747 } 747 }
748 748
749 template<typename _Key, typename _Value, 749 template<typename _Key, typename _Value,
760 __chc, __cit, __uk>::iterator> 760 __chc, __cit, __uk>::iterator>
761 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 761 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
762 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 762 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
763 equal_range(const key_type& __k) 763 equal_range(const key_type& __k)
764 { 764 {
765 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 765 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
766 std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 766 std::size_t __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
767 _Node** __head = _M_buckets + __n; 767 _Node** __head = _M_buckets + __n;
768 _Node* __p = _M_find_node(*__head, __k, __code); 768 _Node* __p = _M_find_node(*__head, __k, __code0);
769 769
770 if (__p) 770 if (__p)
771 { 771 {
772 _Node* __p1 = __p->_M_next; 772 _Node* __p1 = __p->_M_next;
773 for (; __p1; __p1 = __p1->_M_next) 773 for (; __p1; __p1 = __p1->_M_next)
774 if (!this->_M_compare(__k, __code, __p1)) 774 if (!this->_M_compare(__k, __code0, __p1))
775 break; 775 break;
776 776
777 iterator __first(__p, __head); 777 iterator __first(__p, __head);
778 iterator __last(__p1, __head); 778 iterator __last(__p1, __head);
779 if (!__p1) 779 if (!__p1)
798 __chc, __cit, __uk>::const_iterator> 798 __chc, __cit, __uk>::const_iterator>
799 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 799 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
800 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 800 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
801 equal_range(const key_type& __k) const 801 equal_range(const key_type& __k) const
802 { 802 {
803 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 803 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
804 std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 804 std::size_t __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
805 _Node** __head = _M_buckets + __n; 805 _Node** __head = _M_buckets + __n;
806 _Node* __p = _M_find_node(*__head, __k, __code); 806 _Node* __p = _M_find_node(*__head, __k, __code0);
807 807
808 if (__p) 808 if (__p)
809 { 809 {
810 _Node* __p1 = __p->_M_next; 810 _Node* __p1 = __p->_M_next;
811 for (; __p1; __p1 = __p1->_M_next) 811 for (; __p1; __p1 = __p1->_M_next)
812 if (!this->_M_compare(__k, __code, __p1)) 812 if (!this->_M_compare(__k, __code0, __p1))
813 break; 813 break;
814 814
815 const_iterator __first(__p, __head); 815 const_iterator __first(__p, __head);
816 const_iterator __last(__p1, __head); 816 const_iterator __last(__p1, __head);
817 if (!__p1) 817 if (!__p1)
832 _Equal, _H1, _H2, _Hash, _RehashPolicy, 832 _Equal, _H1, _H2, _Hash, _RehashPolicy,
833 __chc, __cit, __uk>::_Node* 833 __chc, __cit, __uk>::_Node*
834 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 834 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
835 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 835 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
836 _M_find_node(_Node* __p, const key_type& __k, 836 _M_find_node(_Node* __p, const key_type& __k,
837 typename _Hashtable::_Hash_code_type __code) const 837 typename _Hashtable::_Hash_code_type __code0) const
838 { 838 {
839 for (; __p; __p = __p->_M_next) 839 for (; __p; __p = __p->_M_next)
840 if (this->_M_compare(__k, __code, __p)) 840 if (this->_M_compare(__k, __code0, __p))
841 return __p; 841 return __p;
842 return 0; 842 return 0;
843 } 843 }
844 844
845 // Insert v in bucket n (assumes no element with its key already present). 845 // Insert v in bucket n (assumes no element with its key already present).
851 _H1, _H2, _Hash, _RehashPolicy, 851 _H1, _H2, _Hash, _RehashPolicy,
852 __chc, __cit, __uk>::iterator 852 __chc, __cit, __uk>::iterator
853 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 853 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
854 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 854 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
855 _M_insert_bucket(const value_type& __v, size_type __n, 855 _M_insert_bucket(const value_type& __v, size_type __n,
856 typename _Hashtable::_Hash_code_type __code) 856 typename _Hashtable::_Hash_code_type __code0)
857 { 857 {
858 std::pair<bool, std::size_t> __do_rehash 858 std::pair<bool, std::size_t> __do_rehash
859 = _M_rehash_policy._M_need_rehash(_M_bucket_count, 859 = _M_rehash_policy._M_need_rehash(_M_bucket_count,
860 _M_element_count, 1); 860 _M_element_count, 1);
861 861
866 __try 866 __try
867 { 867 {
868 if (__do_rehash.first) 868 if (__do_rehash.first)
869 { 869 {
870 const key_type& __k = this->_M_extract(__v); 870 const key_type& __k = this->_M_extract(__v);
871 __n = this->_M_bucket_index(__k, __code, __do_rehash.second); 871 __n = this->_M_bucket_index(__k, __code0, __do_rehash.second);
872 _M_rehash(__do_rehash.second); 872 _M_rehash(__do_rehash.second);
873 } 873 }
874 874
875 __new_node->_M_next = _M_buckets[__n]; 875 __new_node->_M_next = _M_buckets[__n];
876 this->_M_store_code(__new_node, __code); 876 this->_M_store_code(__new_node, __code0);
877 _M_buckets[__n] = __new_node; 877 _M_buckets[__n] = __new_node;
878 ++_M_element_count; 878 ++_M_element_count;
879 return iterator(__new_node, _M_buckets + __n); 879 return iterator(__new_node, _M_buckets + __n);
880 } 880 }
881 __catch(...) 881 __catch(...)
897 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 897 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
898 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 898 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
899 _M_insert(const value_type& __v, std::tr1::true_type) 899 _M_insert(const value_type& __v, std::tr1::true_type)
900 { 900 {
901 const key_type& __k = this->_M_extract(__v); 901 const key_type& __k = this->_M_extract(__v);
902 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 902 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
903 size_type __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 903 size_type __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
904 904
905 if (_Node* __p = _M_find_node(_M_buckets[__n], __k, __code)) 905 if (_Node* __p = _M_find_node(_M_buckets[__n], __k, __code0))
906 return std::make_pair(iterator(__p, _M_buckets + __n), false); 906 return std::make_pair(iterator(__p, _M_buckets + __n), false);
907 return std::make_pair(_M_insert_bucket(__v, __n, __code), true); 907 return std::make_pair(_M_insert_bucket(__v, __n, __code0), true);
908 } 908 }
909 909
910 // Insert v unconditionally. 910 // Insert v unconditionally.
911 template<typename _Key, typename _Value, 911 template<typename _Key, typename _Value,
912 typename _Allocator, typename _ExtractKey, typename _Equal, 912 typename _Allocator, typename _ExtractKey, typename _Equal,
924 _M_element_count, 1); 924 _M_element_count, 1);
925 if (__do_rehash.first) 925 if (__do_rehash.first)
926 _M_rehash(__do_rehash.second); 926 _M_rehash(__do_rehash.second);
927 927
928 const key_type& __k = this->_M_extract(__v); 928 const key_type& __k = this->_M_extract(__v);
929 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 929 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
930 size_type __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 930 size_type __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
931 931
932 // First find the node, avoid leaking new_node if compare throws. 932 // First find the node, avoid leaking new_node if compare throws.
933 _Node* __prev = _M_find_node(_M_buckets[__n], __k, __code); 933 _Node* __prev = _M_find_node(_M_buckets[__n], __k, __code0);
934 _Node* __new_node = _M_allocate_node(__v); 934 _Node* __new_node = _M_allocate_node(__v);
935 935
936 if (__prev) 936 if (__prev)
937 { 937 {
938 __new_node->_M_next = __prev->_M_next; 938 __new_node->_M_next = __prev->_M_next;
941 else 941 else
942 { 942 {
943 __new_node->_M_next = _M_buckets[__n]; 943 __new_node->_M_next = _M_buckets[__n];
944 _M_buckets[__n] = __new_node; 944 _M_buckets[__n] = __new_node;
945 } 945 }
946 this->_M_store_code(__new_node, __code); 946 this->_M_store_code(__new_node, __code0);
947 947
948 ++_M_element_count; 948 ++_M_element_count;
949 return iterator(__new_node, _M_buckets + __n); 949 return iterator(__new_node, _M_buckets + __n);
950 } 950 }
951 951
1041 __chc, __cit, __uk>::size_type 1041 __chc, __cit, __uk>::size_type
1042 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, 1042 _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal,
1043 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: 1043 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
1044 erase(const key_type& __k) 1044 erase(const key_type& __k)
1045 { 1045 {
1046 typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); 1046 typename _Hashtable::_Hash_code_type __code0 = this->_M_hash_code(__k);
1047 std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); 1047 std::size_t __n = this->_M_bucket_index(__k, __code0, _M_bucket_count);
1048 size_type __result = 0; 1048 size_type __result = 0;
1049 1049
1050 _Node** __slot = _M_buckets + __n; 1050 _Node** __slot = _M_buckets + __n;
1051 while (*__slot && !this->_M_compare(__k, __code, *__slot)) 1051 while (*__slot && !this->_M_compare(__k, __code0, *__slot))
1052 __slot = &((*__slot)->_M_next); 1052 __slot = &((*__slot)->_M_next);
1053 1053
1054 _Node** __saved_slot = 0; 1054 _Node** __saved_slot = 0;
1055 while (*__slot && this->_M_compare(__k, __code, *__slot)) 1055 while (*__slot && this->_M_compare(__k, __code0, *__slot))
1056 { 1056 {
1057 // _GLIBCXX_RESOLVE_LIB_DEFECTS 1057 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1058 // 526. Is it undefined if a function in the standard changes 1058 // 526. Is it undefined if a function in the standard changes
1059 // in parameters? 1059 // in parameters?
1060 if (&this->_M_extract((*__slot)->_M_v) != &__k) 1060 if (&this->_M_extract((*__slot)->_M_v) != &__k)