From beb5d0f44c0d60a05204f3661275ebb770038a6a Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Sat, 30 Sep 2006 00:39:20 +0000 Subject: [PATCH] constructor_destructor_no_store_hash_fn_imps.hpp: Formating fixes. 2006-09-29 Benjamin Kosnik * include/ext/pb_ds/detail/cc_hash_table_map_/ constructor_destructor_no_store_hash_fn_imps.hpp: Formating fixes. * include/ext/pb_ds/detail/basic_tree_policy/ null_node_metadata.hpp: Same. * include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp: Same. * include/ext/pb_ds/detail/basic_types.hpp: Same. * include/ext/pb_ds/detail/list_update_policy/ mtf_lu_policy_imp.hpp: Same. * include/ext/pb_ds/detail/list_update_policy/ counter_lu_metadata.hpp: Same. * include/ext/pb_ds/detail/list_update_policy/ sample_update_policy.hpp: Same. * include/ext/pb_ds/detail/list_update_policy/ counter_lu_policy_imp.hpp: Same. * include/ext/pb_ds/list_update_policy.hpp: Same. From-SVN: r117328 --- libstdc++-v3/ChangeLog | 18 ++ .../basic_tree_policy/null_node_metadata.hpp | 14 +- .../include/ext/pb_ds/detail/basic_types.hpp | 239 ++++-------------- .../binary_heap_/const_point_iterator.hpp | 49 +--- ...uctor_destructor_no_store_hash_fn_imps.hpp | 3 +- .../counter_lu_metadata.hpp | 64 +---- .../counter_lu_policy_imp.hpp | 11 +- .../list_update_policy/mtf_lu_policy_imp.hpp | 8 +- .../sample_update_policy.hpp | 21 +- .../include/ext/pb_ds/list_update_policy.hpp | 9 +- 10 files changed, 122 insertions(+), 314 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9a5de15946d..43570848a37 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,21 @@ +2006-09-29 Benjamin Kosnik + + * include/ext/pb_ds/detail/cc_hash_table_map_/ + constructor_destructor_no_store_hash_fn_imps.hpp: Formating fixes. + * include/ext/pb_ds/detail/basic_tree_policy/ + null_node_metadata.hpp: Same. + * include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp: Same. +-- * include/ext/pb_ds/detail/basic_types.hpp: Same. + * include/ext/pb_ds/detail/list_update_policy/ + mtf_lu_policy_imp.hpp: Same. + * include/ext/pb_ds/detail/list_update_policy/ + counter_lu_metadata.hpp: Same. + * include/ext/pb_ds/detail/list_update_policy/ + sample_update_policy.hpp: Same. + * include/ext/pb_ds/detail/list_update_policy/ + counter_lu_policy_imp.hpp: Same. + * include/ext/pb_ds/list_update_policy.hpp: Same. + 2006-09-29 Benjamin Kosnik Howard Hinnant Paolo Carlini diff --git a/libstdc++-v3/include/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp b/libstdc++-v3/include/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp index 1e050f807ac..23991987097 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp @@ -53,31 +53,21 @@ namespace pb_ds { namespace detail { - template struct dumconst_node_iterator { private: - typedef - typename types_traits< - Key, - Data, - Allocator, - false>::pointer - const_iterator; + typedef typename types_traits::pointer const_iterator; public: typedef const_iterator value_type; - typedef const_iterator const_reference; - typedef const_reference reference; }; struct null_node_metadata { }; - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_NULL_NODE_METADATA_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/basic_types.hpp b/libstdc++-v3/include/ext/pb_ds/detail/basic_types.hpp index 4bad6c04a7f..817ea25b5f2 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/basic_types.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/basic_types.hpp @@ -56,64 +56,34 @@ namespace pb_ds { namespace detail { - - template + template struct value_type_base; -#define PB_DS_CLASS_T_DEC \ - template +#define PB_DS_CLASS_T_DEC \ + template -#define PB_DS_CLASS_C_DEC \ - value_type_base< \ - Key, \ - Mapped, \ - Allocator, \ - false> +#define PB_DS_CLASS_C_DEC \ + value_type_base /** * Specialization of value_type_base for the case where the hash value - * is not stored alongside each value. + * is not stored alongside each value. **/ - template - struct value_type_base< - Key, - Mapped, - Allocator, - false> + template + struct value_type_base { - - typedef - typename Allocator::template rebind< - Mapped>::other - mapped_type_allocator; - + typedef typename Allocator::template rebind::other mapped_type_allocator; typedef typename mapped_type_allocator::value_type mapped_type; - typedef typename mapped_type_allocator::pointer mapped_pointer; - - typedef - typename mapped_type_allocator::const_pointer - const_mapped_pointer; - + typedef typename mapped_type_allocator::const_pointer const_mapped_pointer; typedef typename mapped_type_allocator::reference mapped_reference; + typedef typename mapped_type_allocator::const_reference const_mapped_reference; - typedef - typename mapped_type_allocator::const_reference - const_mapped_reference; - - typedef - typename Allocator::template rebind< - std::pair >::other - value_type_allocator; - + typedef typename Allocator::template rebind >::other value_type_allocator; typedef typename value_type_allocator::value_type value_type; - typedef typename value_type_allocator::pointer pointer; - typedef typename value_type_allocator::const_pointer const_pointer; - typedef typename value_type_allocator::reference reference; - typedef typename value_type_allocator::const_reference const_reference; struct stored_value_type @@ -123,139 +93,78 @@ namespace pb_ds }; #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC -#define PB_DS_CLASS_T_DEC \ - template +#define PB_DS_CLASS_T_DEC \ + template -#define PB_DS_CLASS_C_DEC \ - value_type_base< \ - Key, \ - Mapped, \ - Allocator, \ - true> +#define PB_DS_CLASS_C_DEC \ + value_type_base /** * Specialization of value_type_base for the case where the hash value - * is stored alongside each value. + * is stored alongside each value. **/ - template - struct value_type_base< - Key, - Mapped, - Allocator, - true> + template + struct value_type_base { - - typedef - typename Allocator::template rebind< - Mapped>::other - mapped_type_allocator; - + typedef typename Allocator::template rebind::other mapped_type_allocator; typedef typename mapped_type_allocator::value_type mapped_type; - typedef typename mapped_type_allocator::pointer mapped_pointer; - - typedef - typename mapped_type_allocator::const_pointer - const_mapped_pointer; - + typedef typename mapped_type_allocator::const_pointer const_mapped_pointer; typedef typename mapped_type_allocator::reference mapped_reference; + typedef typename mapped_type_allocator::const_reference const_mapped_reference; - typedef - typename mapped_type_allocator::const_reference - const_mapped_reference; - - typedef - typename Allocator::template rebind< - std::pair >::other - value_type_allocator; - + typedef typename Allocator::template rebind >::other value_type_allocator; typedef typename value_type_allocator::value_type value_type; - typedef typename value_type_allocator::pointer pointer; - typedef typename value_type_allocator::const_pointer const_pointer; - typedef typename value_type_allocator::reference reference; - typedef typename value_type_allocator::const_reference const_reference; struct stored_value_type { value_type m_value; - typename Allocator::size_type m_hash; }; }; #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC -#define PB_DS_CLASS_T_DEC \ - template +#define PB_DS_CLASS_T_DEC \ + template -#define PB_DS_CLASS_C_DEC \ - value_type_base< \ - Key, \ - null_mapped_type, \ - Allocator, \ - false> +#define PB_DS_CLASS_C_DEC \ + value_type_base /** * Specialization of value_type_base for the case where the hash value - * is not stored alongside each value. + * is not stored alongside each value. **/ - template - struct value_type_base< - Key, - null_mapped_type, - Allocator, - false> + template + struct value_type_base { - - typedef - typename Allocator::template rebind< - null_mapped_type>::other - mapped_type_allocator; - + typedef typename Allocator::template rebind::other mapped_type_allocator; typedef typename mapped_type_allocator::value_type mapped_type; - typedef typename mapped_type_allocator::pointer mapped_pointer; - - typedef - typename mapped_type_allocator::const_pointer - const_mapped_pointer; - + typedef typename mapped_type_allocator::const_pointer const_mapped_pointer; typedef typename mapped_type_allocator::reference mapped_reference; - - typedef - typename mapped_type_allocator::const_reference - const_mapped_reference; + typedef typename mapped_type_allocator::const_reference const_mapped_reference; typedef Key value_type; - typedef - typename Allocator::template rebind< - value_type>::other - value_type_allocator; - + typedef typename Allocator::template rebind::other value_type_allocator; typedef typename value_type_allocator::pointer pointer; - typedef typename value_type_allocator::const_pointer const_pointer; - typedef typename value_type_allocator::reference reference; - typedef typename value_type_allocator::const_reference const_reference; struct stored_value_type { - Key m_value; + value_type m_value; }; - public: static null_mapped_type s_null_mapped; }; @@ -263,73 +172,42 @@ namespace pb_ds null_mapped_type PB_DS_CLASS_C_DEC::s_null_mapped; #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC -#define PB_DS_CLASS_T_DEC \ - template +#define PB_DS_CLASS_T_DEC \ + template -#define PB_DS_CLASS_C_DEC \ - value_type_base< \ - Key, \ - null_mapped_type, \ - Allocator, \ - true> +#define PB_DS_CLASS_C_DEC \ + value_type_base /** * Specialization of value_type_base for the case where the hash value - * is stored alongside each value. + * is stored alongside each value. **/ - template - struct value_type_base< - Key, - null_mapped_type, - Allocator, - true> + template + struct value_type_base { - - typedef - typename Allocator::template rebind< - null_mapped_type>::other - mapped_type_allocator; - + typedef typename Allocator::template rebind::other mapped_type_allocator; typedef typename mapped_type_allocator::value_type mapped_type; - typedef typename mapped_type_allocator::pointer mapped_pointer; - - typedef - typename mapped_type_allocator::const_pointer - const_mapped_pointer; - + typedef typename mapped_type_allocator::const_pointer const_mapped_pointer; typedef typename mapped_type_allocator::reference mapped_reference; - - typedef - typename mapped_type_allocator::const_reference - const_mapped_reference; + typedef typename mapped_type_allocator::const_reference const_mapped_reference; typedef Key value_type; - typedef - typename Allocator::template rebind< - Key>::other - value_type_allocator; - + typedef typename Allocator::template rebind::other value_type_allocator; typedef typename value_type_allocator::pointer pointer; - typedef typename value_type_allocator::const_pointer const_pointer; - typedef typename value_type_allocator::reference reference; - typedef typename value_type_allocator::const_reference const_reference; struct stored_value_type { - Key m_value; - + value_type m_value; typename Allocator::size_type m_hash; }; - public: static null_mapped_type s_null_mapped; }; @@ -337,41 +215,32 @@ namespace pb_ds null_mapped_type PB_DS_CLASS_C_DEC::s_null_mapped; #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_C_DEC - template + template struct no_throw_copies; - template + template struct no_throw_copies { typedef - integral_constant::value&& - is_simple::value> + integral_constant::value && is_simple::value> indicator; }; template - struct no_throw_copies< - Key, - null_mapped_type> + struct no_throw_copies { - typedef - integral_constant::value> - indicator; + typedef integral_constant::value> indicator; }; template struct comp_hash_ { - typedef std::pair< Size_Type, Size_Type> comp_hash; + typedef std::pair comp_hash; }; - } // namespace detail } // namespace pb_ds -#endif // #ifndef PB_DS_BASIC_TYPES_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp index 670b6ecf07b..3a50cd6c4b1 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp @@ -55,29 +55,15 @@ namespace pb_ds { namespace detail { - -#define PB_DS_CLASS_T_DEC \ - template - -#define PB_DS_CLASS_C_DEC \ - binary_heap_const_point_iterator_ - // Const point-type iterator. - template + template class binary_heap_const_point_iterator_ { - protected: - typedef - typename Allocator::template rebind< - Entry>::other::pointer - entry_pointer; + typedef typename Allocator::template rebind::other::pointer entry_pointer; public: - // Category. typedef trivial_iterator_tag iterator_category; @@ -88,31 +74,24 @@ namespace pb_ds typedef Value_Type value_type; // Iterator's pointer type. - typedef - typename Allocator::template rebind< - value_type>::other::pointer + typedef typename Allocator::template rebind::other::pointer pointer; // Iterator's const pointer type. typedef - typename Allocator::template rebind< - value_type>::other::const_pointer + typename Allocator::template rebind::other::const_pointer const_pointer; // Iterator's reference type. typedef - typename Allocator::template rebind< - value_type>::other::reference + typename Allocator::template rebind::other::reference reference; // Iterator's const reference type. typedef - typename Allocator::template rebind< - value_type>::other::const_reference + typename Allocator::template rebind::other::const_reference const_reference; - public: - inline binary_heap_const_point_iterator_(entry_pointer p_e) : m_p_e(p_e) { } @@ -123,7 +102,7 @@ namespace pb_ds // Copy constructor. inline - binary_heap_const_point_iterator_(const PB_DS_CLASS_C_DEC& other) + binary_heap_const_point_iterator_(const binary_heap_const_point_iterator_& other) : m_p_e(other.m_p_e) { } @@ -132,7 +111,7 @@ namespace pb_ds operator->() const { _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL); - return to_ptr(integral_constant()); + return to_ptr(integral_constant()); } // Access. @@ -140,17 +119,17 @@ namespace pb_ds operator*() const { _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL); - return *to_ptr(integral_constant()); + return *to_ptr(integral_constant()); } // Compares content to a different iterator object. inline bool - operator==(const PB_DS_CLASS_C_DEC& other) const + operator==(const binary_heap_const_point_iterator_& other) const { return m_p_e == other.m_p_e; } // Compares content (negatively) to a different iterator object. inline bool - operator!=(const PB_DS_CLASS_C_DEC& other) const + operator!=(const binary_heap_const_point_iterator_& other) const { return m_p_e != other.m_p_e; } private: @@ -165,10 +144,6 @@ namespace pb_ds public: entry_pointer m_p_e; }; - -#undef PB_DS_CLASS_T_DEC -#undef PB_DS_CLASS_C_DEC - } // namespace detail } // namespace pb_ds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp index 6aac3795c1e..f2b41b37bca 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp @@ -48,7 +48,8 @@ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: -constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant) +constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, + false_type) { // Following lines might throw an exception. entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp index 744f72b48ca..d8cd2891683 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp @@ -48,81 +48,45 @@ namespace pb_ds { namespace detail { - template class counter_lu_policy_base; - // A list-update metadata type that moves elements to the front of the list based on the counter algorithm. + // A list-update metadata type that moves elements to the front of + // the list based on the counter algorithm. template class counter_lu_metadata { - public: - typedef Size_Type size_type; private: counter_lu_metadata(size_type init_count) : m_count(init_count) { } - private: - mutable size_type m_count; + friend class counter_lu_policy_base; - friend class counter_lu_policy_base; + mutable size_type m_count; }; - template - class counter_lu_policy_base; - -#define PB_DS_CLASS_T_DEC \ - template - -#define PB_DS_CLASS_C_DEC \ - counter_lu_policy_base< \ - Size_Type> - template class counter_lu_policy_base { protected: typedef Size_Type size_type; - protected: - counter_lu_metadata< - Size_Type> - operator()(size_type max_size) const; + counter_lu_metadata + operator()(size_type max_size) const + { return counter_lu_metadata(rand() % max_size); } template bool - operator()(Metadata_Reference r_data, size_type m_max_count) const; + operator()(Metadata_Reference r_data, size_type m_max_count) const + { + if (++r_data.m_count != m_max_count) + return false; + r_data.m_count = 0; + return true; + } }; - - PB_DS_CLASS_T_DEC - counter_lu_metadata< - Size_Type> - PB_DS_CLASS_C_DEC:: - operator()(size_type m_max_count) const - { - return (counter_lu_metadata(rand() % m_max_count)); - } - - PB_DS_CLASS_T_DEC - template - inline bool - PB_DS_CLASS_C_DEC:: - operator()(Metadata_Reference r_data, size_type m_max_count) const - { - if (++r_data.m_count != m_max_count) - return (false); - - r_data.m_count = 0; - - return (true); - } - } // namespace detail } // namespace pb_ds - -#undef PB_DS_CLASS_T_DEC - -#undef PB_DS_CLASS_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp index 2d0521ab1f8..42e1bdf2836 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp @@ -45,18 +45,13 @@ */ PB_DS_CLASS_T_DEC -detail::counter_lu_metadata< - typename Allocator::size_type> +detail::counter_lu_metadata PB_DS_CLASS_C_DEC:: operator()() const -{ - return (base_type::operator()(max_count)); -} +{ return (base_type::operator()(max_count)); } PB_DS_CLASS_T_DEC bool PB_DS_CLASS_C_DEC:: operator()(metadata_reference r_data) const -{ - return (base_type::operator()(r_data, max_count)); -} +{ return (base_type::operator()(r_data, max_count)); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp index 0a6180cd558..8f9d9460df2 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp @@ -51,15 +51,11 @@ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::metadata_type PB_DS_CLASS_C_DEC:: operator()() const -{ - return s_metadata; -} +{ return s_metadata; } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: operator()(metadata_reference /*r_data*/) const -{ - return true; -} +{ return true; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp index d16a629424e..8cfc1f2310d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp @@ -48,36 +48,33 @@ #define PB_DS_SAMPLE_UPDATE_POLICY_HPP // A sample list-update policy. -class sample_update_policy +struct sample_update_policy { - -public: - // Default constructor. sample_update_policy(); // Copy constructor. - sample_update_policy(const sample_update_policy& other); + sample_update_policy(const sample_update_policy&); // Swaps content. inline void swap(sample_update_policy& other); protected: - // Metadata on which this functor operates. typedef some_metadata_type metadata_type; -protected: - // Creates a metadata object. metadata_type operator()() const; - // Decides whether a metadata object should be moved to the front of the list. A list-update based containers object will call this method to decide whether to move a node to the front of the list. The method shoule return true if the node should be moved to the front of the list. + // Decides whether a metadata object should be moved to the front of + // the list. A list-update based containers object will call this + // method to decide whether to move a node to the front of the + // list. The method shoule return true if the node should be moved + // to the front of the list. bool - operator()(metadata_reference r_data) const; - + operator()(metadata_reference) const; }; -#endif // #ifndef PB_DS_SAMPLE_UPDATE_POLICY_HPP +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/list_update_policy.hpp b/libstdc++-v3/include/ext/pb_ds/list_update_policy.hpp index 0ddd1af71f3..cfe2a2c375e 100644 --- a/libstdc++-v3/include/ext/pb_ds/list_update_policy.hpp +++ b/libstdc++-v3/include/ext/pb_ds/list_update_policy.hpp @@ -78,7 +78,8 @@ namespace pb_ds metadata_type operator()() const; - // Decides whether a metadata object should be moved to the front of the list. + // Decides whether a metadata object should be moved to the front + // of the list. inline bool operator()(metadata_reference r_metadata) const; @@ -94,7 +95,8 @@ namespace pb_ds #define PB_DS_CLASS_T_DEC template #define PB_DS_CLASS_C_DEC counter_lu_policy - // A list-update policy that moves elements to the front of the list based on the counter algorithm. + // A list-update policy that moves elements to the front of the list + // based on the counter algorithm. template > class counter_lu_policy : private detail::counter_lu_policy_base @@ -120,7 +122,8 @@ namespace pb_ds metadata_type operator()() const; - // Decides whether a metadata object should be moved to the front of the list. + // Decides whether a metadata object should be moved to the front + // of the list. bool operator()(metadata_reference r_metadata) const; -- 2.30.2