Commit beb5d0f4 by Benjamin Kosnik Committed by Benjamin Kosnik

constructor_destructor_no_store_hash_fn_imps.hpp: Formating fixes.

2006-09-29  Benjamin Kosnik  <bkoz@redhat.com>

	* 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
parent 2e67b718
2006-09-29 Benjamin Kosnik <bkoz@redhat.com> 2006-09-29 Benjamin Kosnik <bkoz@redhat.com>
* 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 <bkoz@redhat.com>
Howard Hinnant <hhinnant@apple.com> Howard Hinnant <hhinnant@apple.com>
Paolo Carlini <pcarlini@suse.de> Paolo Carlini <pcarlini@suse.de>
......
...@@ -53,31 +53,21 @@ namespace pb_ds ...@@ -53,31 +53,21 @@ namespace pb_ds
{ {
namespace detail namespace detail
{ {
template<typename Key, class Data, class Allocator> template<typename Key, class Data, class Allocator>
struct dumconst_node_iterator struct dumconst_node_iterator
{ {
private: private:
typedef typedef typename types_traits<Key, Data, Allocator, false>::pointer const_iterator;
typename types_traits<
Key,
Data,
Allocator,
false>::pointer
const_iterator;
public: public:
typedef const_iterator value_type; typedef const_iterator value_type;
typedef const_iterator const_reference; typedef const_iterator const_reference;
typedef const_reference reference; typedef const_reference reference;
}; };
struct null_node_metadata struct null_node_metadata
{ }; { };
} // namespace detail } // namespace detail
} // namespace pb_ds } // namespace pb_ds
#endif // #ifndef PB_DS_NULL_NODE_METADATA_HPP #endif
...@@ -55,29 +55,15 @@ namespace pb_ds ...@@ -55,29 +55,15 @@ namespace pb_ds
{ {
namespace detail namespace detail
{ {
#define PB_DS_CLASS_T_DEC \
template<typename Value_Type, typename Entry, bool Simple, class Allocator>
#define PB_DS_CLASS_C_DEC \
binary_heap_const_point_iterator_<Value_Type, Entry, Simple, Allocator>
// Const point-type iterator. // Const point-type iterator.
template<typename Value_Type, template<typename Value_Type, typename Entry, bool Simple,
typename Entry, typename Allocator>
bool Simple,
class Allocator>
class binary_heap_const_point_iterator_ class binary_heap_const_point_iterator_
{ {
protected: protected:
typedef typedef typename Allocator::template rebind<Entry>::other::pointer entry_pointer;
typename Allocator::template rebind<
Entry>::other::pointer
entry_pointer;
public: public:
// Category. // Category.
typedef trivial_iterator_tag iterator_category; typedef trivial_iterator_tag iterator_category;
...@@ -88,31 +74,24 @@ namespace pb_ds ...@@ -88,31 +74,24 @@ namespace pb_ds
typedef Value_Type value_type; typedef Value_Type value_type;
// Iterator's pointer type. // Iterator's pointer type.
typedef typedef typename Allocator::template rebind<value_type>::other::pointer
typename Allocator::template rebind<
value_type>::other::pointer
pointer; pointer;
// Iterator's const pointer type. // Iterator's const pointer type.
typedef typedef
typename Allocator::template rebind< typename Allocator::template rebind<value_type>::other::const_pointer
value_type>::other::const_pointer
const_pointer; const_pointer;
// Iterator's reference type. // Iterator's reference type.
typedef typedef
typename Allocator::template rebind< typename Allocator::template rebind<value_type>::other::reference
value_type>::other::reference
reference; reference;
// Iterator's const reference type. // Iterator's const reference type.
typedef typedef
typename Allocator::template rebind< typename Allocator::template rebind<value_type>::other::const_reference
value_type>::other::const_reference
const_reference; const_reference;
public:
inline inline
binary_heap_const_point_iterator_(entry_pointer p_e) : m_p_e(p_e) binary_heap_const_point_iterator_(entry_pointer p_e) : m_p_e(p_e)
{ } { }
...@@ -123,7 +102,7 @@ namespace pb_ds ...@@ -123,7 +102,7 @@ namespace pb_ds
// Copy constructor. // Copy constructor.
inline 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) : m_p_e(other.m_p_e)
{ } { }
...@@ -132,7 +111,7 @@ namespace pb_ds ...@@ -132,7 +111,7 @@ namespace pb_ds
operator->() const operator->() const
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_e != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL);
return to_ptr(integral_constant<int,Simple>()); return to_ptr(integral_constant<int, Simple>());
} }
// Access. // Access.
...@@ -140,17 +119,17 @@ namespace pb_ds ...@@ -140,17 +119,17 @@ namespace pb_ds
operator*() const operator*() const
{ {
_GLIBCXX_DEBUG_ASSERT(m_p_e != NULL); _GLIBCXX_DEBUG_ASSERT(m_p_e != NULL);
return *to_ptr(integral_constant<int,Simple>()); return *to_ptr(integral_constant<int, Simple>());
} }
// Compares content to a different iterator object. // Compares content to a different iterator object.
inline bool 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; } { return m_p_e == other.m_p_e; }
// Compares content (negatively) to a different iterator object. // Compares content (negatively) to a different iterator object.
inline bool 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; } { return m_p_e != other.m_p_e; }
private: private:
...@@ -165,10 +144,6 @@ namespace pb_ds ...@@ -165,10 +144,6 @@ namespace pb_ds
public: public:
entry_pointer m_p_e; entry_pointer m_p_e;
}; };
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
} // namespace detail } // namespace detail
} // namespace pb_ds } // namespace pb_ds
......
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline void inline void
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
constructor_insert_new_imp(const_mapped_reference r_val, size_type pos, integral_constant<int,false>) constructor_insert_new_imp(const_mapped_reference r_val, size_type pos,
false_type)
{ {
// Following lines might throw an exception. // Following lines might throw an exception.
entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator); entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
......
...@@ -48,81 +48,45 @@ namespace pb_ds ...@@ -48,81 +48,45 @@ namespace pb_ds
{ {
namespace detail namespace detail
{ {
template<typename Size_Type> template<typename Size_Type>
class counter_lu_policy_base; 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<typename Size_Type = size_t> template<typename Size_Type = size_t>
class counter_lu_metadata class counter_lu_metadata
{ {
public: public:
typedef Size_Type size_type; typedef Size_Type size_type;
private: private:
counter_lu_metadata(size_type init_count) : m_count(init_count) counter_lu_metadata(size_type init_count) : m_count(init_count)
{ } { }
private: friend class counter_lu_policy_base<size_type>;
mutable size_type m_count;
friend class counter_lu_policy_base<Size_Type>; mutable size_type m_count;
}; };
template<typename Size_Type> template<typename Size_Type>
class counter_lu_policy_base;
#define PB_DS_CLASS_T_DEC \
template<typename Size_Type>
#define PB_DS_CLASS_C_DEC \
counter_lu_policy_base< \
Size_Type>
template<typename Size_Type>
class counter_lu_policy_base class counter_lu_policy_base
{ {
protected: protected:
typedef Size_Type size_type; typedef Size_Type size_type;
protected: counter_lu_metadata<size_type>
counter_lu_metadata< operator()(size_type max_size) const
Size_Type> { return counter_lu_metadata<Size_Type>(rand() % max_size); }
operator()(size_type max_size) const;
template<typename Metadata_Reference> template<typename Metadata_Reference>
bool 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<Size_Type>(rand() % m_max_count));
}
PB_DS_CLASS_T_DEC
template<typename Metadata_Reference>
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 detail
} // namespace pb_ds } // namespace pb_ds
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC
...@@ -45,18 +45,13 @@ ...@@ -45,18 +45,13 @@
*/ */
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
detail::counter_lu_metadata< detail::counter_lu_metadata<typename Allocator::size_type>
typename Allocator::size_type>
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
operator()() const operator()() const
{ { return (base_type::operator()(max_count)); }
return (base_type::operator()(max_count));
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
bool bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
operator()(metadata_reference r_data) const operator()(metadata_reference r_data) const
{ { return (base_type::operator()(r_data, max_count)); }
return (base_type::operator()(r_data, max_count));
}
...@@ -51,15 +51,11 @@ PB_DS_CLASS_T_DEC ...@@ -51,15 +51,11 @@ PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::metadata_type typename PB_DS_CLASS_C_DEC::metadata_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
operator()() const operator()() const
{ { return s_metadata; }
return s_metadata;
}
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
inline bool inline bool
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
operator()(metadata_reference /*r_data*/) const operator()(metadata_reference /*r_data*/) const
{ { return true; }
return true;
}
...@@ -48,36 +48,33 @@ ...@@ -48,36 +48,33 @@
#define PB_DS_SAMPLE_UPDATE_POLICY_HPP #define PB_DS_SAMPLE_UPDATE_POLICY_HPP
// A sample list-update policy. // A sample list-update policy.
class sample_update_policy struct sample_update_policy
{ {
public:
// Default constructor. // Default constructor.
sample_update_policy(); sample_update_policy();
// Copy constructor. // Copy constructor.
sample_update_policy(const sample_update_policy& other); sample_update_policy(const sample_update_policy&);
// Swaps content. // Swaps content.
inline void inline void
swap(sample_update_policy& other); swap(sample_update_policy& other);
protected: protected:
// Metadata on which this functor operates. // Metadata on which this functor operates.
typedef some_metadata_type metadata_type; typedef some_metadata_type metadata_type;
protected:
// Creates a metadata object. // Creates a metadata object.
metadata_type metadata_type
operator()() const; 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 bool
operator()(metadata_reference r_data) const; operator()(metadata_reference) const;
}; };
#endif // #ifndef PB_DS_SAMPLE_UPDATE_POLICY_HPP #endif
...@@ -78,7 +78,8 @@ namespace pb_ds ...@@ -78,7 +78,8 @@ namespace pb_ds
metadata_type metadata_type
operator()() const; 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 inline bool
operator()(metadata_reference r_metadata) const; operator()(metadata_reference r_metadata) const;
...@@ -94,7 +95,8 @@ namespace pb_ds ...@@ -94,7 +95,8 @@ namespace pb_ds
#define PB_DS_CLASS_T_DEC template<size_t Max_Count, class Allocator> #define PB_DS_CLASS_T_DEC template<size_t Max_Count, class Allocator>
#define PB_DS_CLASS_C_DEC counter_lu_policy<Max_Count, Allocator> #define PB_DS_CLASS_C_DEC counter_lu_policy<Max_Count, Allocator>
// 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<size_t Max_Count = 5, typename Allocator = std::allocator<char> > template<size_t Max_Count = 5, typename Allocator = std::allocator<char> >
class counter_lu_policy class counter_lu_policy
: private detail::counter_lu_policy_base<typename Allocator::size_type> : private detail::counter_lu_policy_base<typename Allocator::size_type>
...@@ -120,7 +122,8 @@ namespace pb_ds ...@@ -120,7 +122,8 @@ namespace pb_ds
metadata_type metadata_type
operator()() const; 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 bool
operator()(metadata_reference r_metadata) const; operator()(metadata_reference r_metadata) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment