[PATCH][Hashtable 0/6] Code review

François Dumont frs.dumont@gmail.com
Mon Dec 9 21:16:00 GMT 2019


This patch also require an update of the printers.py file.

Here is an updated version.

François

On 11/17/19 9:42 PM, François Dumont wrote:
> This is the begining of a patch series for _Hashtable
>
> Initial patch to clarify code. I was tired to see true/false or 
> true_type/false_type without knowing what was true/false.
>
> I also made code more consistent by chosing to specialize methods 
> through usage of __unique_keys_t/__multi_keys_t rather than calling 
> them _M_[multi]_XXX.
>
>
>     * include/bits/hashtable_policy.h (__detail::__unique_keys_t): New.
>     (__detail::__multi_keys_t): New.
>     (__detail::__constant_iterators_t): New.
>     (__detail::__mutable_iterators_t): New.
>     (__detail::__hash_cached_t): New.
>     (__detail::__hash_not_cached_t): New.
>     (_Hash_node<>): Change _Cache_hash_code template parameter from 
> bool to
>     typename. Adapt partial specializations.
>     (_Node_iterator_base<>): Likewise.
>     (operator==(const _Node_iterator_base<>&,const 
> _Node_iterator_base<>&)):
>     Adapt.
>     (operator!=(const _Node_iterator_base<>&,const 
> _Node_iterator_base<>&)):
>     Adapt.
>     (_Node_iterator<>): Change __constant_iterators and __cache template
>     parameters from bool to typename.
>     (_Node_const_iterator<>): Likewise.
>     (_Map_base<>): Change _Unique_keys template parameter from bool to
>     typename. Adapt partial specializations.
>     (_Insert<>): Change _Constant_iterators template parameter from 
> bool to
>     typename. Adapt partial specializations.
>     (_Local_iterator_base<>): Change __cache_hash_code template parameter
>     from bool to typename. Adapt partial specialization.
>     (_Hash_code_base<>): Likewise.
>     (operator==(const _Local_iterator_base<>&,
>     const _Local_iterator_base<>&)): Adapt.
>     (operator!=(const _Local_iterator_base<>&,
>     const _Local_iterator_base<>&)):
>     Adapt.
>     (_Local_iterator<>): Change __constant_iterators and __cache template
>     parameters from bool to typename.
>     (_Local_const_iterator<>): Likewise.
>     (_Hashtable_base<>): Adapt.
>     (_Equal_hash_code<>): Adapt.
>     (_Equality<>): Adapt.
>     * include/bits/hashtable.h (_Hashtable<>): Replace occurences of
>     true_type/false_type by respoectively __unique_type_t/__multi_type_t.
>     (_M_insert_unique_node(const key_type&, size_t, __hash_code,
>     __node_type*, size_t)): Replace by...
>     (_M_insert_node(__unique_keys_t, size_t, __hash_code, __node_type*,
>     size_t)): ...this.
>     (_M_insert_muti_node(__node_type*, const key_type&, __hash_code,
>     __node_type*)): Replace by...
>     (_M_insert_node(__multi_keys_t, __node_type*, __hash_code,
>     __node_type*)): ...this.
>     (_M_reinsert_node(node_type&&)): Replace by...
>     (_M_reinsert_node(node_type&&, __unique_keys_t)): ...this.
>     (_M_reinsert_node(const_iterator, node_type&&, __unique_keys_t)): 
> New,
>     forward to latter.
>     (_M_reinsert_node_multi(const_iterator, node_type&&)): Replace by...
>     (_M_reinsert_node(const_iterator, node_type&&, __multi_keys_t)):
>     ...this.
>     (_M_reinsert_node(node_type&&, __multi_keys_t)): New, forward to 
> latter.
>     (_M_reinsert_node(node_type&&)): New, use latters.
>     (_M_reinsert_node(const_iterator, node_type&&)): Likewise.
>     (_M_merge_unique(_Compatible_Hashtable&)): Replace by...
>     (_M_merge(__unique_keys_t, _Compatible_Hashtable&)): ...this.
>     (_M_merge_multi(_Compatible_Hashtable&)): Replace by...
>     (_M_merge(__multi_keys_t, _Compatible_Hashtable&)): ...this.
>     (_M_merge(_Compatible_Hashtable&)): New, use latters.
>     * include/bits/unordered_map.h
>     (unordered_map<>::insert(const_iterator, node_type&&)): Adapt.
>     (unordered_map<>::merge(unordered_map<>&)): Adapt.
> (unordered_map<>::merge(unordered_multimap<>&)): Adapt.
>     (unordered_multimap<>::insert(node_type&&)): Adapt.
>     (unordered_multimap<>::insert(const_iterator, node_type&&)): Adapt.
> (unordered_multimap<>::merge(unordered_multimap<>&)): Adapt.
> (unordered_multimap<>::merge(unordered_map<>&)): Adapt.
>     * include/bits/unordered_set.h
>     (unordered_set<>::insert(const_iterator, node_type&&)): Adapt.
>     (unordered_set<>::merge(unordered_set<>&)): Adapt.
> (unordered_set<>::merge(unordered_multiset<>&)): Adapt.
>     (unordered_multiset<>::insert(node_type&&)): Adapt.
>     (unordered_multiset<>::insert(const_iterator, node_type&&)): Adapt.
> (unordered_multiset<>::merge(unordered_multiset<>&)): Adapt.
> (unordered_multiset<>::merge(unordered_set<>&)): Adapt.
>
> Tested under Linux x86_64.
>
> François
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable#1.patch
Type: text/x-patch
Size: 53549 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20191209/2566e061/attachment.bin>


More information about the Libstdc++ mailing list