51 #ifdef PB_DS_LU_MAP_TRACE_
60 #ifdef PB_DS_DATA_TRUE_INDICATOR
61 #define PB_DS_LU_NAME lu_map
64 #ifdef PB_DS_DATA_FALSE_INDICATOR
65 #define PB_DS_LU_NAME lu_set
68 #define PB_DS_CLASS_T_DEC \
69 template<typename Key, typename Mapped, typename Eq_Fn, \
70 typename _Alloc, typename Update_Policy>
72 #define PB_DS_CLASS_C_DEC \
73 PB_DS_LU_NAME<Key, Mapped, Eq_Fn, _Alloc, Update_Policy>
75 #define PB_DS_LU_TRAITS_BASE \
76 types_traits<Key, Mapped, _Alloc, false>
79 #define PB_DS_DEBUG_MAP_BASE_C_DEC \
80 debug_map_base<Key, Eq_Fn, \
81 typename rebind_traits<_Alloc, Key>::const_reference>
86 template<
typename Key,
90 typename Update_Policy>
93 protected PB_DS_DEBUG_MAP_BASE_C_DEC,
95 public PB_DS_LU_TRAITS_BASE
101 :
public lu_map_entry_metadata_base<typename Update_Policy::metadata_type>
108 typedef typename entry_alloc_traits::allocator_type entry_allocator;
109 typedef typename entry_alloc_traits::pointer entry_pointer;
110 typedef typename entry_alloc_traits::const_pointer const_entry_pointer;
111 typedef typename entry_alloc_traits::reference entry_reference;
112 typedef typename entry_alloc_traits::const_reference const_entry_reference;
115 typedef typename entry_pointer_alloc_traits::allocator_type entry_pointer_allocator;
116 typedef typename entry_pointer_alloc_traits::pointer entry_pointer_array;
119 typedef typename traits_base::pointer pointer_;
120 typedef typename traits_base::const_pointer const_pointer_;
121 typedef typename traits_base::reference reference_;
122 typedef typename traits_base::const_reference const_reference_;
124 #define PB_DS_GEN_POS entry_pointer
134 #ifdef _GLIBCXX_DEBUG
135 typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
141 typedef _Alloc allocator_type;
142 typedef typename _Alloc::size_type size_type;
143 typedef typename _Alloc::difference_type difference_type;
145 typedef Update_Policy update_policy;
146 typedef typename Update_Policy::metadata_type update_metadata;
147 typedef typename traits_base::key_type key_type;
148 typedef typename traits_base::key_pointer key_pointer;
149 typedef typename traits_base::key_const_pointer key_const_pointer;
150 typedef typename traits_base::key_reference key_reference;
151 typedef typename traits_base::key_const_reference key_const_reference;
152 typedef typename traits_base::mapped_type mapped_type;
153 typedef typename traits_base::mapped_pointer mapped_pointer;
154 typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
155 typedef typename traits_base::mapped_reference mapped_reference;
156 typedef typename traits_base::mapped_const_reference mapped_const_reference;
158 typedef typename traits_base::pointer pointer;
159 typedef typename traits_base::const_pointer const_pointer;
160 typedef typename traits_base::reference reference;
161 typedef typename traits_base::const_reference const_reference;
163 #ifdef PB_DS_DATA_TRUE_INDICATOR
164 typedef point_iterator_ point_iterator;
167 #ifdef PB_DS_DATA_FALSE_INDICATOR
168 typedef point_const_iterator_ point_iterator;
171 typedef point_const_iterator_ point_const_iterator;
173 #ifdef PB_DS_DATA_TRUE_INDICATOR
174 typedef iterator_ iterator;
177 #ifdef PB_DS_DATA_FALSE_INDICATOR
178 typedef const_iterator_ iterator;
181 typedef const_iterator_ const_iterator;
186 PB_DS_LU_NAME(
const PB_DS_CLASS_C_DEC&);
191 template<
typename It>
192 PB_DS_LU_NAME(It, It);
195 swap(PB_DS_CLASS_C_DEC&);
203 _GLIBCXX_NODISCARD
inline bool
206 inline mapped_reference
207 operator[](key_const_reference r_key)
209 #ifdef PB_DS_DATA_TRUE_INDICATOR
210 _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
211 return insert(std::make_pair(r_key, mapped_type())).first->second;
214 return traits_base::s_null_type;
219 insert(const_reference);
221 inline point_iterator
222 find(key_const_reference r_key)
224 _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
225 entry_pointer p_e = find_imp(r_key);
226 return point_iterator(p_e == 0 ? 0: &p_e->m_value);
229 inline point_const_iterator
230 find(key_const_reference r_key)
const
232 _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
233 entry_pointer p_e = find_imp(r_key);
234 return point_const_iterator(p_e == 0 ? 0: &p_e->m_value);
238 erase(key_const_reference);
240 template<
typename Pred>
250 inline const_iterator
256 inline const_iterator
259 #ifdef _GLIBCXX_DEBUG
261 assert_valid(
const char* file,
int line)
const;
264 #ifdef PB_DS_LU_MAP_TRACE_
271 template<
typename It>
273 copy_from_range(It, It);
276 #ifdef PB_DS_DATA_TRUE_INDICATOR
277 friend class iterator_;
280 friend class const_iterator_;
283 allocate_new_entry(const_reference, false_type);
286 allocate_new_entry(const_reference, true_type);
288 template<
typename Metadata>
290 init_entry_metadata(entry_pointer, type_to_type<Metadata>);
293 init_entry_metadata(entry_pointer, type_to_type<null_type>);
299 erase_next(entry_pointer);
302 actual_erase_entry(entry_pointer);
305 inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos)
const
307 r_pos = r_pos->m_p_next;
308 r_p_value = (r_pos == 0) ? 0 : &r_pos->m_value;
311 template<
typename Metadata>
313 apply_update(entry_pointer, type_to_type<Metadata>);
316 apply_update(entry_pointer, type_to_type<null_type>);
319 find_imp(key_const_reference)
const;
321 static entry_allocator s_entry_allocator;
322 static Eq_Fn s_eq_fn;
323 static Update_Policy s_update_policy;
324 static type_to_type<update_metadata> s_metadata_type_indicator;
327 mutable entry_pointer m_p_l;
339 #undef PB_DS_CLASS_T_DEC
340 #undef PB_DS_CLASS_C_DEC
341 #undef PB_DS_LU_TRAITS_BASE
342 #undef PB_DS_DEBUG_MAP_BASE_C_DEC
GNU extensions for policy-based data structures for public use.
Struct holding two objects of arbitrary type.
Represents no type, or absence of type, for template tricks.
Conditional deallocate constructor argument.
Consistent API for accessing allocator-related types.