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
This commit is contained in:
Benjamin Kosnik 2006-09-30 00:39:20 +00:00 committed by Benjamin Kosnik
parent 2e67b71839
commit beb5d0f44c
10 changed files with 122 additions and 314 deletions

View File

@ -1,3 +1,21 @@
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>
Paolo Carlini <pcarlini@suse.de>

View File

@ -53,31 +53,21 @@ namespace pb_ds
{
namespace detail
{
template<typename Key, class Data, class Allocator>
struct dumconst_node_iterator
{
private:
typedef
typename types_traits<
Key,
Data,
Allocator,
false>::pointer
const_iterator;
typedef typename types_traits<Key, Data, Allocator, false>::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

View File

@ -56,64 +56,34 @@ namespace pb_ds
{
namespace detail
{
template<typename Key, class Mapped, class Allocator, bool Store_Hash>
template<typename Key, typename Mapped, typename Allocator, bool Store_Hash>
struct value_type_base;
#define PB_DS_CLASS_T_DEC \
template<typename Key, class Mapped, class Allocator>
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Allocator>
#define PB_DS_CLASS_C_DEC \
value_type_base< \
Key, \
Mapped, \
Allocator, \
false>
#define PB_DS_CLASS_C_DEC \
value_type_base<Key, Mapped, Allocator, false>
/**
* 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<typename Key, class Mapped, class Allocator>
struct value_type_base<
Key,
Mapped,
Allocator,
false>
template<typename Key, typename Mapped, typename Allocator>
struct value_type_base<Key, Mapped, Allocator, false>
{
typedef
typename Allocator::template rebind<
Mapped>::other
mapped_type_allocator;
typedef typename Allocator::template rebind<Mapped>::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<const Key, Mapped> >::other
value_type_allocator;
typedef typename Allocator::template rebind<std::pair<const Key, Mapped> >::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<typename Key, class Mapped, class Allocator>
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Mapped, typename Allocator>
#define PB_DS_CLASS_C_DEC \
value_type_base< \
Key, \
Mapped, \
Allocator, \
true>
#define PB_DS_CLASS_C_DEC \
value_type_base<Key, Mapped, Allocator, true>
/**
* Specialization of value_type_base for the case where the hash value
* is stored alongside each value.
* is stored alongside each value.
**/
template<typename Key, class Mapped, class Allocator>
struct value_type_base<
Key,
Mapped,
Allocator,
true>
template<typename Key, typename Mapped, typename Allocator>
struct value_type_base<Key, Mapped, Allocator, true>
{
typedef
typename Allocator::template rebind<
Mapped>::other
mapped_type_allocator;
typedef typename Allocator::template rebind<Mapped>::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<const Key, Mapped> >::other
value_type_allocator;
typedef typename Allocator::template rebind<std::pair<const Key, Mapped> >::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<typename Key, class Allocator>
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Allocator>
#define PB_DS_CLASS_C_DEC \
value_type_base< \
Key, \
null_mapped_type, \
Allocator, \
false>
#define PB_DS_CLASS_C_DEC \
value_type_base<Key, null_mapped_type, Allocator, false>
/**
* 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<typename Key, class Allocator>
struct value_type_base<
Key,
null_mapped_type,
Allocator,
false>
template<typename Key, typename Allocator>
struct value_type_base<Key, null_mapped_type, Allocator, false>
{
typedef
typename Allocator::template rebind<
null_mapped_type>::other
mapped_type_allocator;
typedef typename Allocator::template rebind<null_mapped_type>::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<value_type>::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<typename Key, class Allocator>
#define PB_DS_CLASS_T_DEC \
template<typename Key, typename Allocator>
#define PB_DS_CLASS_C_DEC \
value_type_base< \
Key, \
null_mapped_type, \
Allocator, \
true>
#define PB_DS_CLASS_C_DEC \
value_type_base<Key, null_mapped_type, Allocator, true>
/**
* Specialization of value_type_base for the case where the hash value
* is stored alongside each value.
* is stored alongside each value.
**/
template<typename Key, class Allocator>
struct value_type_base<
Key,
null_mapped_type,
Allocator,
true>
template<typename Key, typename Allocator>
struct value_type_base<Key, null_mapped_type, Allocator, true>
{
typedef
typename Allocator::template rebind<
null_mapped_type>::other
mapped_type_allocator;
typedef typename Allocator::template rebind<null_mapped_type>::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<value_type>::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<typename Key, class Mapped>
template<typename Key, typename Mapped>
struct no_throw_copies;
template<typename Key, class Mapped>
template<typename Key, typename Mapped>
struct no_throw_copies
{
typedef
integral_constant<int,
is_simple<Key>::value&&
is_simple<Mapped>::value>
integral_constant<int, is_simple<Key>::value && is_simple<Mapped>::value>
indicator;
};
template<typename Key>
struct no_throw_copies<
Key,
null_mapped_type>
struct no_throw_copies<Key, null_mapped_type>
{
typedef
integral_constant<int,
is_simple<Key>::value>
indicator;
typedef integral_constant<int, is_simple<Key>::value> indicator;
};
template<typename Size_Type>
struct comp_hash_
{
typedef std::pair< Size_Type, Size_Type> comp_hash;
typedef std::pair<Size_Type, Size_Type> comp_hash;
};
} // namespace detail
} // namespace pb_ds
#endif // #ifndef PB_DS_BASIC_TYPES_HPP
#endif

View File

@ -55,29 +55,15 @@ namespace pb_ds
{
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.
template<typename Value_Type,
typename Entry,
bool Simple,
class Allocator>
template<typename Value_Type, typename Entry, bool Simple,
typename Allocator>
class binary_heap_const_point_iterator_
{
protected:
typedef
typename Allocator::template rebind<
Entry>::other::pointer
entry_pointer;
typedef typename Allocator::template rebind<Entry>::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<value_type>::other::pointer
pointer;
// Iterator's const pointer type.
typedef
typename Allocator::template rebind<
value_type>::other::const_pointer
typename Allocator::template rebind<value_type>::other::const_pointer
const_pointer;
// Iterator's reference type.
typedef
typename Allocator::template rebind<
value_type>::other::reference
typename Allocator::template rebind<value_type>::other::reference
reference;
// Iterator's const reference type.
typedef
typename Allocator::template rebind<
value_type>::other::const_reference
typename Allocator::template rebind<value_type>::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<int,Simple>());
return to_ptr(integral_constant<int, Simple>());
}
// Access.
@ -140,17 +119,17 @@ namespace pb_ds
operator*() const
{
_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.
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

View File

@ -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<int,false>)
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);

View File

@ -48,81 +48,45 @@ namespace pb_ds
{
namespace detail
{
template<typename Size_Type>
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>
class counter_lu_metadata
{
public:
typedef Size_Type size_type;
private:
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>;
};
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
{
protected:
typedef Size_Type size_type;
protected:
counter_lu_metadata<
Size_Type>
operator()(size_type max_size) const;
counter_lu_metadata<size_type>
operator()(size_type max_size) const
{ return counter_lu_metadata<Size_Type>(rand() % max_size); }
template<typename Metadata_Reference>
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 pb_ds
#undef PB_DS_CLASS_T_DEC
#undef PB_DS_CLASS_C_DEC

View File

@ -45,18 +45,13 @@
*/
PB_DS_CLASS_T_DEC
detail::counter_lu_metadata<
typename Allocator::size_type>
detail::counter_lu_metadata<typename Allocator::size_type>
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)); }

View File

@ -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; }

View File

@ -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

View File

@ -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<size_t Max_Count, class 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> >
class counter_lu_policy
: private detail::counter_lu_policy_base<typename Allocator::size_type>
@ -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;