{
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
};
#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;
};
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;
};
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
{
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;
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)
{ }
// 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)
{ }
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(m_p_e != NULL);
- return to_ptr(integral_constant<int,Simple>());
+ return to_ptr(integral_constant<int, Simple>());
}
// Access.
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:
public:
entry_pointer m_p_e;
};
-
-#undef PB_DS_CLASS_T_DEC
-#undef PB_DS_CLASS_C_DEC
-
} // namespace detail
} // 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:
- mutable size_type m_count;
+ friend class counter_lu_policy_base<size_type>;
- friend class counter_lu_policy_base<Size_Type>;
+ mutable size_type m_count;
};
- 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