41 #ifndef PB_DS_TRIE_POLICY_HPP
42 #define PB_DS_TRIE_POLICY_HPP
47 #include <ext/pb_ds/detail/trie_policy/trie_policy_base.hpp>
52 template<
typename Const_Node_Iterator,
53 typename Node_Iterator,
54 typename E_Access_Traits,
56 struct null_trie_node_update
59 #define PB_DS_CLASS_T_DEC \
60 template<typename String, typename String::value_type Min_E_Val, typename String::value_type Max_E_Val, bool Reverse, typename Allocator>
62 #define PB_DS_CLASS_C_DEC \
63 string_trie_e_access_traits<String, Min_E_Val,Max_E_Val,Reverse,Allocator>
67 typename String::value_type Min_E_Val = detail::__numeric_traits<typename String::value_type>::__min,
68 typename String::value_type Max_E_Val = detail::__numeric_traits<typename String::value_type>::__max,
71 struct string_trie_e_access_traits
74 typedef typename Allocator::size_type size_type;
75 typedef String key_type;
76 typedef typename Allocator::template rebind<key_type>::other key_rebind;
77 typedef typename key_rebind::const_reference const_key_reference;
85 typedef typename detail::__conditional_type<Reverse, typename String::const_reverse_iterator, typename String::const_iterator>::__type const_iterator;
88 typedef typename std::iterator_traits<const_iterator>::value_type e_type;
92 min_e_val = Min_E_Val,
93 max_e_val = Max_E_Val,
94 max_size = max_e_val - min_e_val + 1
96 PB_DS_STATIC_ASSERT(min_max_size, max_size >= 2);
100 inline static const_iterator
101 begin(const_key_reference);
105 inline static const_iterator
106 end(const_key_reference);
109 inline static size_type
114 inline static const_iterator
117 inline static const_iterator
120 inline static const_iterator
123 inline static const_iterator
126 static detail::integral_constant<int, Reverse> s_rev_ind;
129 #include <ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp>
131 #undef PB_DS_CLASS_T_DEC
132 #undef PB_DS_CLASS_C_DEC
134 #define PB_DS_CLASS_T_DEC \
135 template<typename Const_Node_Iterator,typename Node_Iterator,class E_Access_Traits, typename Allocator>
137 #define PB_DS_CLASS_C_DEC \
138 trie_prefix_search_node_update<Const_Node_Iterator, Node_Iterator, E_Access_Traits,Allocator>
140 #define PB_DS_BASE_C_DEC \
141 detail::trie_policy_base<Const_Node_Iterator,Node_Iterator,E_Access_Traits, Allocator>
145 template<
typename Const_Node_Iterator,
146 typename Node_Iterator,
147 typename E_Access_Traits,
149 class trie_prefix_search_node_update :
private PB_DS_BASE_C_DEC
152 typedef PB_DS_BASE_C_DEC base_type;
155 typedef typename base_type::key_type key_type;
156 typedef typename base_type::const_key_reference const_key_reference;
159 typedef E_Access_Traits e_access_traits;
162 typedef typename e_access_traits::const_iterator const_e_iterator;
165 typedef Allocator allocator_type;
168 typedef typename allocator_type::size_type size_type;
169 typedef detail::null_node_metadata metadata_type;
170 typedef Const_Node_Iterator const_node_iterator;
171 typedef Node_Iterator node_iterator;
172 typedef typename const_node_iterator::value_type const_iterator;
173 typedef typename node_iterator::value_type iterator;
178 prefix_range(const_key_reference)
const;
183 prefix_range(const_key_reference);
188 prefix_range(const_e_iterator, const_e_iterator)
const;
193 prefix_range(const_e_iterator, const_e_iterator);
198 operator()(node_iterator node_it, const_node_iterator end_nd_it)
const;
202 virtual const_iterator
210 virtual const_node_iterator
211 node_begin()
const = 0;
214 virtual node_iterator
218 virtual const_node_iterator
219 node_end()
const = 0;
222 virtual node_iterator
226 virtual const e_access_traits&
227 get_e_access_traits()
const = 0;
230 next_child(node_iterator, const_e_iterator, const_e_iterator,
231 node_iterator,
const e_access_traits&);
234 #include <ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp>
236 #undef PB_DS_CLASS_C_DEC
238 #define PB_DS_CLASS_C_DEC \
239 trie_order_statistics_node_update<Const_Node_Iterator, Node_Iterator,E_Access_Traits, Allocator>
242 template<
typename Const_Node_Iterator,
243 typename Node_Iterator,
244 typename E_Access_Traits,
246 class trie_order_statistics_node_update :
private PB_DS_BASE_C_DEC
249 typedef PB_DS_BASE_C_DEC base_type;
252 typedef E_Access_Traits e_access_traits;
253 typedef typename e_access_traits::const_iterator const_e_iterator;
254 typedef Allocator allocator_type;
255 typedef typename allocator_type::size_type size_type;
256 typedef typename base_type::key_type key_type;
257 typedef typename base_type::const_key_reference const_key_reference;
259 typedef size_type metadata_type;
260 typedef Const_Node_Iterator const_node_iterator;
261 typedef Node_Iterator node_iterator;
262 typedef typename const_node_iterator::value_type const_iterator;
263 typedef typename node_iterator::value_type iterator;
269 inline const_iterator
270 find_by_order(size_type)
const;
277 find_by_order(size_type);
285 order_of_key(const_key_reference)
const;
293 order_of_prefix(const_e_iterator, const_e_iterator)
const;
296 typedef typename base_type::const_reference const_reference;
297 typedef typename base_type::const_pointer const_pointer;
299 typedef typename Allocator::template rebind<metadata_type>::other metadata_rebind;
300 typedef typename metadata_rebind::const_reference const_metadata_reference;
301 typedef typename metadata_rebind::reference metadata_reference;
317 virtual const_node_iterator
318 node_begin()
const = 0;
321 virtual node_iterator
326 virtual const_node_iterator
327 node_end()
const = 0;
330 virtual node_iterator
334 virtual e_access_traits&
335 get_e_access_traits() = 0;
341 operator()(node_iterator, const_node_iterator)
const;
345 ~trie_order_statistics_node_update();
348 #include <ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp>
350 #undef PB_DS_CLASS_T_DEC
351 #undef PB_DS_CLASS_C_DEC
352 #undef PB_DS_BASE_C_DEC
integral_constant< bool, true > true_type
typedef for true_type
Struct holding two objects of arbitrary type.
constexpr const _Tp * begin(initializer_list< _Tp > __ils)
Return an iterator pointing to the first element of the initilizer_list.
integral_constant< bool, false > false_type
typedef for false_type
constexpr const _Tp * end(initializer_list< _Tp > __ils)
Return an iterator pointing to one past the last element of the initilizer_list.
The standard allocator, as per [20.4].Further details: http://gcc.gnu.org/onlinedocs/libstdc++/manual...