42 #ifndef PB_DS_TRIE_POLICY_HPP
43 #define PB_DS_TRIE_POLICY_HPP
52 #define PB_DS_CLASS_T_DEC \
53 template<typename String, typename String::value_type Min_E_Val, \
54 typename String::value_type Max_E_Val, bool Reverse, \
57 #define PB_DS_CLASS_C_DEC \
58 trie_string_access_traits<String, Min_E_Val,Max_E_Val,Reverse,_Alloc>
71 typename String::value_type Min_E_Val = detail::__numeric_traits<typename String::value_type>::__min,
72 typename String::value_type Max_E_Val = detail::__numeric_traits<typename String::value_type>::__max,
78 typedef typename _Alloc::size_type size_type;
79 typedef String key_type;
80 typedef typename _Alloc::template rebind<key_type> __rebind_k;
81 typedef typename __rebind_k::other::const_reference key_const_reference;
89 typedef typename detail::__conditional_type<Reverse, \
90 typename String::const_reverse_iterator, \
94 typedef typename std::iterator_traits<const_iterator>::value_type
e_type;
98 min_e_val = Min_E_Val,
99 max_e_val = Max_E_Val,
100 max_size = max_e_val - min_e_val + 1
102 PB_DS_STATIC_ASSERT(min_max_size, max_size >= 2);
107 begin(key_const_reference);
112 end(key_const_reference);
115 inline static size_type
120 begin_imp(key_const_reference, detail::false_type);
123 begin_imp(key_const_reference, detail::true_type);
126 end_imp(key_const_reference, detail::false_type);
129 end_imp(key_const_reference, detail::true_type);
131 static detail::integral_constant<int, Reverse> s_rev_ind;
136 #undef PB_DS_CLASS_T_DEC
137 #undef PB_DS_CLASS_C_DEC
139 #define PB_DS_CLASS_T_DEC \
140 template<typename Node_CItr,typename Node_Itr, \
141 typename _ATraits, typename _Alloc>
143 #define PB_DS_CLASS_C_DEC \
144 trie_prefix_search_node_update<Node_CItr, Node_Itr, \
147 #define PB_DS_TRIE_POLICY_BASE \
148 detail::trie_policy_base<Node_CItr,Node_Itr,_ATraits, _Alloc>
152 template<
typename Node_CItr,
159 typedef PB_DS_TRIE_POLICY_BASE
base_type;
162 typedef typename base_type::key_type key_type;
163 typedef typename base_type::key_const_reference key_const_reference;
177 typedef Node_Itr node_iterator;
178 typedef Node_CItr node_const_iterator;
179 typedef typename node_iterator::value_type iterator;
180 typedef typename node_const_iterator::value_type const_iterator;
205 operator()(node_iterator node_it, node_const_iterator end_nd_it)
const;
213 virtual const_iterator
221 virtual node_const_iterator
222 node_begin()
const = 0;
225 virtual node_iterator
229 virtual node_const_iterator
230 node_end()
const = 0;
233 virtual node_iterator
238 get_access_traits()
const = 0;
243 #undef PB_DS_CLASS_C_DEC
245 #define PB_DS_CLASS_C_DEC \
246 trie_order_statistics_node_update<Node_CItr, Node_Itr, \
250 template<
typename Node_CItr,
257 typedef PB_DS_TRIE_POLICY_BASE
base_type;
260 typedef _ATraits access_traits;
261 typedef typename access_traits::const_iterator a_const_iterator;
262 typedef _Alloc allocator_type;
263 typedef typename allocator_type::size_type size_type;
264 typedef typename base_type::key_type key_type;
265 typedef typename base_type::key_const_reference key_const_reference;
267 typedef size_type metadata_type;
268 typedef Node_CItr node_const_iterator;
269 typedef Node_Itr node_iterator;
270 typedef typename node_const_iterator::value_type const_iterator;
271 typedef typename node_iterator::value_type iterator;
277 inline const_iterator
307 operator()(node_iterator, node_const_iterator)
const;
310 typedef typename base_type::const_reference const_reference;
311 typedef typename base_type::const_pointer const_pointer;
313 typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
314 typedef typename __rebind_m::other __rebind_ma;
315 typedef typename __rebind_ma::const_reference metadata_const_reference;
316 typedef typename __rebind_ma::reference metadata_reference;
332 virtual node_const_iterator
333 node_begin()
const = 0;
336 virtual node_iterator
341 virtual node_const_iterator
342 node_end()
const = 0;
345 virtual node_iterator
349 virtual access_traits&
350 get_access_traits() = 0;
355 #undef PB_DS_CLASS_T_DEC
356 #undef PB_DS_CLASS_C_DEC
357 #undef PB_DS_TRIE_POLICY_BASE
static size_type e_pos(e_type e)
Maps an element to a position.
_ATraits access_traits
Element access traits.
The standard allocator, as per [20.4].
static const_iterator begin(key_const_reference)
Returns a const_iterator to the first element of key_const_reference agumnet.
detail::__conditional_type< Reverse, typename String::const_reverse_iterator, typename String::const_iterator >::__type const_iterator
Element const iterator type.
const_iterator find_by_order(size_type) const
Finds an entry by __order. Returns a const_iterator to the entry with the __order order...
Base class for trie policies.
size_type order_of_prefix(a_const_iterator, a_const_iterator) const
Returns the order of a prefix within a sequence. For exapmle, if [b, e] is the smallest prefix...
size_type order_of_key(key_const_reference) const
Returns the order of a key within a sequence. For exapmle, if r_key is the smallest key...
A node updator that allows tries to be searched for the range of values that match a certain prefix...
allocator_type::size_type size_type
Size type.
void operator()(node_iterator, node_const_iterator) const
Updates the rank of a node through a node_iterator node_it; end_nd_it is the end node iterator...
_Alloc allocator_type
_Alloc type.
access_traits::const_iterator a_const_iterator
Const element iterator.
std::iterator_traits< const_iterator >::value_type e_type
Element type.
Functor updating ranks of entrees.
void operator()(node_iterator node_it, node_const_iterator end_nd_it) const
Called to update a node's metadata.
Struct holding two objects of arbitrary type.
Represents no type, or absence of type, for template tricks.
std::pair< const_iterator, const_iterator > prefix_range(key_const_reference) const
Finds the const iterator range corresponding to all values whose prefixes match r_key.
static const_iterator end(key_const_reference)
Returns a const_iterator to the after-last element of key_const_reference argument.