GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
OrderedMultimap.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_CORE_DATA_ORDERED_MULTIMAP_HPP
5#define GREM_CORE_DATA_ORDERED_MULTIMAP_HPP
6
8
11
12#include <algorithm> // std::min, std::max, std::equal, std::lexicographical_compare, std::stable_sort, std::inplace_merge, std::equal_range, std::upper_bound, std::lower_bound, std::rotate, std::shift_left
13#include <cstddef> // std::size_t, std::ptrdiff_t
14#include <functional> // std::less
15#include <initializer_list> // std::initializer_list
16#include <iterator> // std::input_iterator, std::sentinel_for, std::reverse_iterator, std::..._iterator_tag, std::begin, std::end
17#include <memory> // std::allocator, std::allocator_traits, std::to_address
18#include <memory_resource> // std::pmr::polymorphic_allocator
19#include <stdexcept> // std::length_error, std::logic_error
20#include <type_traits> // std::is_..._v, std::conditional_t
21#include <utility> // std::move, std::forward, std::swap, std::exchange
22
23namespace grem {
24
25template <typename Key, typename T, typename Compare = std::less<Key>, typename Allocator = std::allocator<Pair<Key, T>>>
27public:
28 using key_type = Key;
29 using mapped_type = T;
30 using key_compare = Compare;
31 using size_type = std::size_t;
32 using allocator_type = Allocator;
33
34private:
35 template <bool Const>
36 class Iterator {
37 private:
38 using V = std::conditional_t<Const, const T, T>;
39
40 public:
43 using difference_type = std::ptrdiff_t;
44 using iterator_category = std::random_access_iterator_tag;
45
46 struct pointer {
47 reference ref;
48
49 [[nodiscard]] constexpr reference* operator->() noexcept {
50 return &ref;
51 }
52 };
53
54 Iterator() noexcept = default;
55
56 constexpr explicit Iterator(value_type* element) noexcept
57 : element(element) {}
58
59 constexpr operator Iterator<true>() const noexcept requires(!Const) {
60 return Iterator<true>{element};
61 }
62
63 [[nodiscard]] constexpr reference operator*() const {
64 GREM_ASSERT(element);
65 return reference{element->first, element->second};
66 }
67
68 [[nodiscard]] constexpr pointer operator->() const {
69 return pointer{**this};
70 }
71
72 [[nodiscard]] constexpr reference operator[](difference_type n) const {
73 GREM_ASSERT(element);
74 return reference{element[n].first, element[n].second};
75 }
76
77 constexpr Iterator& operator++() {
78 ++element;
79 return *this;
80 }
81
82 constexpr Iterator& operator--() {
83 --element;
84 return *this;
85 }
86
87 constexpr Iterator operator++(int) {
88 Iterator old = *this;
89 ++*this;
90 return old;
91 }
92
93 constexpr Iterator operator--(int) {
94 Iterator old = *this;
95 --*this;
96 return old;
97 }
98
99 constexpr Iterator& operator+=(difference_type n) {
100 element += n;
101 return *this;
102 }
103
104 constexpr Iterator& operator-=(difference_type n) {
105 element -= n;
106 return *this;
107 }
108
109 [[nodiscard]] friend constexpr Iterator operator+(Iterator a, difference_type b) {
110 return Iterator{a.element + b};
111 }
112
113 [[nodiscard]] friend constexpr Iterator operator+(difference_type a, Iterator b) {
114 return Iterator{a + b.element};
115 }
116
117 [[nodiscard]] friend constexpr Iterator operator-(Iterator a, difference_type b) {
118 return Iterator{a.element - b};
119 }
120
121 [[nodiscard]] friend constexpr difference_type operator-(Iterator a, Iterator b) {
122 return a.element - b.element;
123 }
124
125 [[nodiscard]] friend constexpr bool operator==(Iterator a, Iterator b) {
126 return a.element == b.element;
127 }
128
129 [[nodiscard]] friend constexpr auto operator<=>(Iterator a, Iterator b) {
130 return a.element <=> b.element;
131 }
132
133 private:
134 value_type* element = nullptr;
135 };
136
137public:
138 using iterator = Iterator<false>;
139 using const_iterator = Iterator<true>;
140 using reverse_iterator = std::reverse_iterator<iterator>;
141 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
142 using value_type = typename iterator::value_type;
143 using difference_type = typename iterator::difference_type;
144 using reference = typename iterator::reference;
145 using const_reference = typename const_iterator::reference;
146 using pointer = typename iterator::pointer;
147 using const_pointer = typename const_iterator::pointer;
148
150 public:
151 [[nodiscard]] bool operator()(const value_type& a, const value_type& b) const {
152 return comp(a.first, b.first);
153 }
154
155 protected:
157
158 value_compare(Compare c)
159 : comp(std::move(c)) {}
160
161 Compare comp;
162 };
163
165 : OrderedMultimap(Compare()) {}
166
167 explicit OrderedMultimap(const Compare& compare, const Allocator& allocator = Allocator())
169 , allocator(allocator) {}
170
171 explicit OrderedMultimap(const Allocator& allocator)
172 : OrderedMultimap(Compare(), allocator) {}
173
174 template <std::input_iterator InputIterator, std::sentinel_for<InputIterator> Sentinel>
175 OrderedMultimap(InputIterator first, Sentinel last, const Compare& compare = Compare(), const Allocator& allocator = Allocator())
177 insert(first, last);
178 }
179
180 template <std::input_iterator InputIterator, std::sentinel_for<InputIterator> Sentinel>
181 OrderedMultimap(InputIterator first, Sentinel last, const Allocator& allocator)
182 : OrderedMultimap(first, last, Compare(), allocator) {}
183
184 OrderedMultimap(std::initializer_list<value_type> ilist, const Compare& compare = Compare(), const Allocator& allocator = Allocator())
185 : OrderedMultimap(ilist.begin(), ilist.end(), compare, allocator) {}
186
187 OrderedMultimap(std::initializer_list<value_type> ilist, const Allocator& allocator)
188 : OrderedMultimap(ilist, Compare(), allocator) {}
189
191 : OrderedMultimap(other, std::allocator_traits<Allocator>::select_on_container_copy_construction(other.get_allocator())) {}
192
193 OrderedMultimap(const OrderedMultimap& other, const Allocator& allocator)
195 *this = other;
196 }
197
199 : elements(std::exchange(other.elements, nullptr))
200 , elementCount(std::exchange(other.elementCount, size_type{0}))
201 , elementCapacity(std::exchange(other.elementCapacity, size_type{0}))
202 , compare(std::move(other.compare))
203 , allocator(other.get_allocator()) {}
204
205 OrderedMultimap(OrderedMultimap&& other, const Allocator& allocator) noexcept // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
207 if constexpr (!std::allocator_traits<Allocator>::is_always_equal::value) {
208 if (allocator != other.get_allocator()) {
209 reserve(other.size());
210 for (size_type index = 0; index < other.size(); ++index) {
211 if constexpr (std::is_nothrow_move_constructible_v<Key> && std::is_nothrow_move_constructible_v<T>) {
212 std::allocator_traits<Allocator>::construct(allocator, std::to_address(elements) + index, std::move(other.elements[index]));
213 } else {
214 std::allocator_traits<Allocator>::construct(allocator, std::to_address(elements) + index, other.elements[index]);
215 }
216 ++elementCount;
217 }
218 other.clear();
219 return;
220 }
221 }
222 elements = std::exchange(other.elements, nullptr);
223 elementCount = std::exchange(other.elementCount, size_type{0});
224 elementCapacity = std::exchange(other.elementCapacity, size_type{0});
225 compare = std::move(other.compare);
226 }
227
229 reset();
230 }
231
233 if (this == &other) {
234 return *this;
235 }
236 if constexpr (std::allocator_traits<Allocator>::propagate_on_container_copy_assignment::value) {
237 if constexpr (!std::allocator_traits<Allocator>::is_always_equal::value) {
238 if (allocator != other.get_allocator()) {
239 reset();
240 }
241 }
242 allocator = other.get_allocator();
243 }
244 while (elementCount > other.elementCount) {
245 --elementCount;
246 std::allocator_traits<Allocator>::destroy(allocator, std::to_address(elements) + elementCount);
247 }
248 reserve(other.size());
249 for (size_type index = 0; index < size(); ++index) {
250 elements[index] = other.elements[index];
251 }
252 for (size_type index = size(); index < other.size(); ++index) {
253 std::allocator_traits<Allocator>::construct(allocator, std::to_address(elements) + index, other.elements[index]);
254 ++elementCount;
255 }
256 return *this;
257 }
258
260 if (this == &other) {
261 return *this;
262 }
263 if constexpr (!std::allocator_traits<Allocator>::propagate_on_container_move_assignment::value) {
264 if constexpr (!std::allocator_traits<Allocator>::is_always_equal::value) {
265 if (allocator != other.get_allocator()) {
266 clear();
267 reserve(other.size());
268 for (size_type index = 0; index < other.size(); ++index) {
269 if constexpr (std::is_nothrow_move_constructible_v<Key> && std::is_nothrow_move_constructible_v<T>) {
270 std::allocator_traits<Allocator>::construct(allocator, std::to_address(elements) + index, std::move(other.elements[index]));
271 } else {
272 std::allocator_traits<Allocator>::construct(allocator, std::to_address(elements) + index, other.elements[index]);
273 }
274 ++elementCount;
275 }
276 other.clear();
277 return *this;
278 }
279 }
280 }
281 reset();
282 elements = std::exchange(other.elements, nullptr);
283 elementCount = std::exchange(other.elementCount, size_type{0});
284 elementCapacity = std::exchange(other.elementCapacity, size_type{0});
285 compare = std::move(other.compare);
286 if constexpr (std::allocator_traits<Allocator>::propagate_on_container_move_assignment::value) {
287 allocator = other.get_allocator();
288 }
289 return *this;
290 }
291
292 OrderedMultimap& operator=(std::initializer_list<value_type> ilist) {
293 clear();
294 insert(ilist);
295 return *this;
296 }
297
298 [[nodiscard]] allocator_type get_allocator() const noexcept {
299 return allocator;
300 }
301
302 [[nodiscard]] iterator begin() noexcept {
303 return iterator{std::to_address(elements)};
304 }
305
306 [[nodiscard]] const_iterator begin() const noexcept {
307 return const_iterator{std::to_address(elements)};
308 }
309
310 [[nodiscard]] const_iterator cbegin() const noexcept {
311 return begin();
312 }
313
314 [[nodiscard]] iterator end() noexcept {
315 return iterator{std::to_address(elements) + elementCount};
316 }
317
318 [[nodiscard]] const_iterator end() const noexcept {
319 return const_iterator{std::to_address(elements) + elementCount};
320 }
321
322 [[nodiscard]] const_iterator cend() const noexcept {
323 return end();
324 }
325
326 [[nodiscard]] reverse_iterator rbegin() noexcept {
327 return reverse_iterator{end()};
328 }
329
330 [[nodiscard]] const_reverse_iterator rbegin() const noexcept {
331 return const_reverse_iterator{end()};
332 }
333
334 [[nodiscard]] const_reverse_iterator crbegin() const noexcept {
335 return rbegin();
336 }
337
338 [[nodiscard]] reverse_iterator rend() noexcept {
339 return reverse_iterator{begin()};
340 }
341
342 [[nodiscard]] const_reverse_iterator rend() const noexcept {
344 }
345
346 [[nodiscard]] const_reverse_iterator crend() const noexcept {
347 return rend();
348 }
349
350 [[nodiscard]] bool empty() const noexcept {
351 return elementCount == 0;
352 }
353
354 [[nodiscard]] size_type size() const noexcept {
355 return elementCount;
356 }
357
358 [[nodiscard]] size_type capacity() const noexcept {
359 return elementCapacity;
360 }
361
362 [[nodiscard]] size_type max_size() const noexcept {
363 return static_cast<size_type>(std::allocator_traits<Allocator>::max_size(allocator));
364 }
365
366 void clear() noexcept {
367 for (size_type index = 0; index < elementCount; ++index) {
368 std::allocator_traits<Allocator>::destroy(allocator, std::to_address(elements) + index);
369 }
370 elementCount = 0;
371 }
372
373 void reserve(size_type newCapacity) {
374 if (newCapacity > max_size()) {
375 throw std::length_error{"newCapacity > max_size()"};
376 }
377
378 const size_type cap = capacity();
379 if (newCapacity <= cap) {
380 return;
381 }
382
383 OrderedMultimap newMap{compare.comp, allocator};
384 newMap.elements = std::allocator_traits<Allocator>::allocate(allocator, newCapacity);
385 newMap.elementCapacity = newCapacity;
386
387 for (size_type index = 0; index < elementCount; ++index) {
388 if constexpr (std::is_nothrow_move_constructible_v<Key> && std::is_nothrow_move_constructible_v<T>) {
389 std::allocator_traits<Allocator>::construct(allocator, std::to_address(newMap.elements) + index, std::move(elements[index]));
390 } else {
391 std::allocator_traits<Allocator>::construct(allocator, std::to_address(newMap.elements) + index, elements[index]);
392 }
393 ++newMap.elementCount;
394 }
396 *this = std::move(newMap);
397 }
398
399 template <typename P>
400 iterator insert(P&& value) {
401 return emplace(std::forward<P>(value));
402 }
403
404 template <typename P>
405 iterator insert(const_iterator pos, P&& value) requires(!std::is_convertible_v<P, const_iterator>) {
406 return emplace_hint(pos, std::forward<P>(value));
407 }
408
409 template <std::input_iterator InputIterator, std::sentinel_for<InputIterator> Sentinel>
410 void insert(InputIterator first, Sentinel last) {
411 const size_type oldSize = size();
412 try {
413 while (first != last) {
414 auto [key, value] = *first++;
415 pushElement(std::move(key), std::move(value));
416 }
417 value_type* const oldElementsBegin = getMutableBegin();
418 value_type* const newElementsBegin = std::to_address(elements) + oldSize;
419 value_type* const elementsEnd = getMutableEnd();
420 std::stable_sort(newElementsBegin, elementsEnd, CompareWrapper{key_comp()});
421 std::inplace_merge(oldElementsBegin, newElementsBegin, elementsEnd, CompareWrapper{key_comp()});
422 } catch (...) {
423 while (size() > oldSize) {
424 popElement();
425 }
426 throw;
427 }
428 }
429
430 void insert(std::initializer_list<value_type> ilist) {
431 insert(ilist.begin(), ilist.end());
432 }
433
434 template <typename R>
435 void insert_range(R&& r) { // NOLINT(cppcoreguidelines-missing-std-forward)
436 insert(std::begin(r), std::end(r));
437 }
438
439 template <typename... Args>
440 iterator emplace(Args&&... args) {
441 Pair<Key, T> value{std::forward<Args>(args)...};
442 const auto last = upper_bound(value.first);
443 return insertElement(last, std::move(value.first), std::move(value.second));
444 }
445
446 template <typename... Args>
447 iterator emplace_hint(const_iterator hint, Args&&... args) {
448 (void)hint;
449 return emplace(std::forward<Args>(args)...);
450 }
451
453 GREM_ASSERT(!empty());
454 const difference_type offset = pos - cbegin();
455 std::shift_left(getMutableBegin() + offset, getMutableEnd(), 1);
456 popElement();
457 return begin() + offset;
458 }
459
460 size_type erase(const Key& key) {
461 const auto [first, last] = equal_range(key);
462 return eraseN(static_cast<size_type>(first - cbegin()), static_cast<size_type>(last - first));
463 }
464
465 template <typename K>
466 size_type erase(K&& x) requires(requires { typename Compare::is_transparent; }) {
467 const auto [first, last] = equal_range(std::forward<K>(x));
468 return eraseN(static_cast<size_type>(first - cbegin()), static_cast<size_type>(last - first));
469 }
470
471 void swap(OrderedMultimap& other) noexcept(
472 std::allocator_traits<Allocator>::propagate_on_container_swap::value || // NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap)
473 (std::allocator_traits<Allocator>::is_always_equal::value && std::is_nothrow_swappable_v<T>)) {
474 if (this == &other) {
475 return;
476 }
477 if constexpr (!std::allocator_traits<Allocator>::propagate_on_container_swap::value && !std::allocator_traits<Allocator>::is_always_equal::value) {
478 if (allocator != other.allocator) {
479 throw std::logic_error{"get_allocator() != other.get_allocator()"};
480 }
481 }
482 using std::swap;
483 swap(elements, other.elements);
484 swap(elementCount, other.elementCount);
485 swap(elementCapacity, other.elementCapacity);
486 if constexpr (std::allocator_traits<Allocator>::propagate_on_container_swap::value) {
487 swap(allocator, other.allocator);
488 }
489 }
490
491 friend void swap(OrderedMultimap& a, OrderedMultimap& b) noexcept {
492 a.swap(b);
493 }
494
495 [[nodiscard]] size_type count(const Key& key) const noexcept {
496 const auto [first, last] = equal_range(key);
497 return static_cast<size_type>(last - first);
498 }
499
500 template <typename K>
501 [[nodiscard]] size_type count(K&& x) const noexcept requires(requires { typename Compare::is_transparent; }) {
502 const auto [first, last] = equal_range(std::forward<K>(x));
503 return static_cast<size_type>(last - first);
504 }
505
506 [[nodiscard]] bool contains(const Key& key) const noexcept {
507 return count(key) > 0;
508 }
509
510 template <typename K>
511 [[nodiscard]] bool contains(K&& x) const noexcept {
512 return count(std::forward<K>(x)) > 0;
513 }
514
515 [[nodiscard]] Pair<iterator, iterator> equal_range(const Key& key) noexcept {
516 const auto [first, last] = std::equal_range(begin(), end(), key, CompareWrapper{key_comp()});
517 return {first, last};
518 }
519
520 template <typename K>
521 [[nodiscard]] Pair<iterator, iterator> equal_range(K&& x) noexcept {
522 const auto [first, last] = std::equal_range(begin(), end(), std::forward<K>(x), CompareWrapper{key_comp()});
523 return {first, last};
524 }
525
526 [[nodiscard]] Pair<const_iterator, const_iterator> equal_range(const Key& key) const noexcept {
527 const auto [first, last] = std::equal_range(begin(), end(), key, CompareWrapper{key_comp()});
528 return {first, last};
529 }
530
531 template <typename K>
532 [[nodiscard]] Pair<const_iterator, const_iterator> equal_range(K&& x) const noexcept {
533 const auto [first, last] = std::equal_range(begin(), end(), std::forward<K>(x), CompareWrapper{key_comp()});
534 return {first, last};
535 }
536
537 [[nodiscard]] iterator lower_bound(const Key& key) noexcept {
538 return std::lower_bound(begin(), end(), key, CompareWrapper{key_comp()});
539 }
540
541 template <typename K>
542 [[nodiscard]] iterator lower_bound(K&& x) noexcept {
543 return std::lower_bound(begin(), end(), std::forward<K>(x), CompareWrapper{key_comp()});
544 }
545
546 [[nodiscard]] const_iterator lower_bound(const Key& key) const noexcept {
547 return std::lower_bound(begin(), end(), key, CompareWrapper{key_comp()});
548 }
549
550 template <typename K>
551 [[nodiscard]] const_iterator lower_bound(K&& x) const noexcept {
552 return std::lower_bound(begin(), end(), std::forward<K>(x), CompareWrapper{key_comp()});
553 }
554
555 [[nodiscard]] iterator upper_bound(const Key& key) noexcept {
556 return std::upper_bound(begin(), end(), key, CompareWrapper{key_comp()});
557 }
558
559 template <typename K>
560 [[nodiscard]] iterator upper_bound(K&& x) noexcept {
561 return std::upper_bound(begin(), end(), std::forward<K>(x), CompareWrapper{key_comp()});
562 }
563
564 [[nodiscard]] const_iterator upper_bound(const Key& key) const noexcept {
565 return std::upper_bound(begin(), end(), key, CompareWrapper{key_comp()});
566 }
567
568 template <typename K>
569 [[nodiscard]] const_iterator upper_bound(K&& x) const noexcept {
570 return std::upper_bound(begin(), end(), std::forward<K>(x), CompareWrapper{key_comp()});
571 }
572
573 [[nodiscard]] key_compare key_comp() const {
574 return compare.comp;
575 }
576
577 [[nodiscard]] value_compare value_comp() const {
578 return compare;
579 }
580
581 [[nodiscard]] constexpr bool operator==(const OrderedMultimap& other) const {
582 return std::equal(begin(), end(), other.begin(), other.end());
583 }
584
585 [[nodiscard]] constexpr bool operator<(const OrderedMultimap& other) const {
586 return std::lexicographical_compare(begin(), end(), other.begin(), other.end());
587 }
588
589 [[nodiscard]] constexpr bool operator<=(const OrderedMultimap& other) const {
590 return !(other < *this);
591 }
592
593 [[nodiscard]] constexpr bool operator>(const OrderedMultimap& other) const {
594 return other < *this;
595 }
596
597 [[nodiscard]] constexpr bool operator>=(const OrderedMultimap& other) const {
598 return !(*this < other);
599 }
600
601 template <typename Predicate>
602 friend size_type erase_if(OrderedMultimap& container, Predicate predicate) {
603 const auto it = std::remove_if(container.getMutableBegin(), container.getMutableEnd(), predicate);
604 const size_type offset = static_cast<size_type>(it - container.getMutableBegin());
605 const size_type count = static_cast<size_type>(container.getMutableEnd() - it);
606 container.eraseN(offset, count);
607 return count;
608 }
609
610protected:
612 [[nodiscard]] bool operator()(const auto& a, const auto& b) const {
613 constexpr auto getKey = []<typename K>(const K& x) -> const auto& {
614 if constexpr (std::is_convertible_v<K, value_type>) {
615 return x.first;
616 } else {
617 return x;
618 }
619 };
620 return comp(getKey(a), getKey(b));
621 }
622
623 Compare comp;
624 };
625
626 [[nodiscard]] value_type* getMutableBegin() {
627 return std::to_address(elements);
628 }
629
630 [[nodiscard]] value_type* getMutableEnd() {
631 return std::to_address(elements) + elementCount;
632 }
633
634 void reset() noexcept {
635 clear();
636 if (elementCapacity > 0) {
637 std::allocator_traits<Allocator>::deallocate(allocator, elements, elementCapacity);
638 elements = nullptr;
639 elementCapacity = 0;
640 }
641 }
642
643 template <typename... Args>
644 void pushElement(Args&&... args) {
645 const size_type newSize = size() + 1;
646 if (newSize > elementCapacity) {
647 reserve(std::max(newSize, elementCapacity + elementCapacity / 2));
648 }
649 std::allocator_traits<Allocator>::construct(allocator, std::to_address(elements) + elementCount, std::forward<Args>(args)...);
650 elementCount = newSize;
651 }
652
653 void popElement() {
654 --elementCount;
655 std::allocator_traits<Allocator>::destroy(allocator, std::to_address(elements) + elementCount);
656 }
657
658 template <typename... Args>
659 iterator insertElement(const_iterator pos, Args&&... args) {
660 const difference_type offset = pos - cbegin();
661 pushElement(std::forward<Args>(args)...);
662 try {
663 std::rotate(getMutableBegin() + offset, getMutableEnd() - 1, getMutableEnd());
664 } catch (...) {
665 popElement();
666 throw;
667 }
668 return begin() + offset;
669 }
670
672 if (count > 0) {
673 GREM_ASSERT(count <= size());
674 const auto newEnd = std::shift_left(getMutableBegin() + static_cast<difference_type>(offset), getMutableEnd(), static_cast<difference_type>(count));
675 for (size_type i = static_cast<size_type>(newEnd - getMutableBegin()); i < elementCount; ++i) {
676 std::allocator_traits<Allocator>::destroy(allocator, std::to_address(elements) + i);
677 }
679 }
680 return count;
681 }
682
683 typename std::allocator_traits<Allocator>::pointer elements{};
686 [[no_unique_address]] value_compare compare;
687 [[no_unique_address]] Allocator allocator;
688};
689
690} // namespace grem
691
692namespace grem::pmr {
693
694template <typename Key, typename T, typename Compare = std::less<Key>>
696
697} // namespace grem::pmr
698
699#endif
#define GREM_ASSERT(expression)
Definition assertions.hpp:77
Compare comp
Definition OrderedMultimap.hpp:161
value_compare(Compare c)
Definition OrderedMultimap.hpp:158
friend OrderedMultimap
Definition OrderedMultimap.hpp:156
bool operator()(const value_type &a, const value_type &b) const
Definition OrderedMultimap.hpp:151
Definition OrderedMultimap.hpp:26
const_iterator lower_bound(const Key &key) const noexcept
Definition OrderedMultimap.hpp:546
allocator_type get_allocator() const noexcept
Definition OrderedMultimap.hpp:298
Iterator< true > const_iterator
Definition OrderedMultimap.hpp:139
iterator insert(const_iterator pos, P &&value)
Definition OrderedMultimap.hpp:405
size_type max_size() const noexcept
Definition OrderedMultimap.hpp:362
Compare key_compare
Definition OrderedMultimap.hpp:30
void insert(std::initializer_list< value_type > ilist)
Definition OrderedMultimap.hpp:430
value_type * getMutableBegin()
Definition OrderedMultimap.hpp:626
key_compare key_comp() const
Definition OrderedMultimap.hpp:573
Pair< iterator, iterator > equal_range(const Key &key) noexcept
Definition OrderedMultimap.hpp:515
iterator emplace(Args &&... args)
Definition OrderedMultimap.hpp:440
const_iterator cend() const noexcept
Definition OrderedMultimap.hpp:322
OrderedMultimap(OrderedMultimap &&other, const Allocator &allocator) noexcept
Definition OrderedMultimap.hpp:205
iterator lower_bound(K &&x) noexcept
Definition OrderedMultimap.hpp:542
OrderedMultimap(const Allocator &allocator)
Definition OrderedMultimap.hpp:171
bool empty() const noexcept
Definition OrderedMultimap.hpp:350
reverse_iterator rbegin() noexcept
Definition OrderedMultimap.hpp:326
iterator insertElement(const_iterator pos, Args &&... args)
Definition OrderedMultimap.hpp:659
size_type elementCapacity
Definition OrderedMultimap.hpp:685
const_iterator cbegin() const noexcept
Definition OrderedMultimap.hpp:310
const_reverse_iterator rend() const noexcept
Definition OrderedMultimap.hpp:342
size_type erase(K &&x)
Definition OrderedMultimap.hpp:466
constexpr bool operator>=(const OrderedMultimap &other) const
Definition OrderedMultimap.hpp:597
OrderedMultimap(InputIterator first, Sentinel last, const Allocator &allocator)
Definition OrderedMultimap.hpp:181
OrderedMultimap(OrderedMultimap &&other) noexcept
Definition OrderedMultimap.hpp:198
constexpr bool operator==(const OrderedMultimap &other) const
Definition OrderedMultimap.hpp:581
size_type count(const Key &key) const noexcept
Definition OrderedMultimap.hpp:495
size_type capacity() const noexcept
Definition OrderedMultimap.hpp:358
size_type count(K &&x) const noexcept
Definition OrderedMultimap.hpp:501
iterator lower_bound(const Key &key) noexcept
Definition OrderedMultimap.hpp:537
void swap(OrderedMultimap &other) noexcept(std::allocator_traits< Allocator >::propagate_on_container_swap::value||//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap)(std::allocator_traits< Allocator >::is_always_equal::value &&std::is_nothrow_swappable_v< T >))
Definition OrderedMultimap.hpp:471
Allocator allocator_type
Definition OrderedMultimap.hpp:32
Key key_type
Definition OrderedMultimap.hpp:28
typename iterator::value_type value_type
Definition OrderedMultimap.hpp:142
Pair< const_iterator, const_iterator > equal_range(K &&x) const noexcept
Definition OrderedMultimap.hpp:532
bool contains(const Key &key) const noexcept
Definition OrderedMultimap.hpp:506
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition OrderedMultimap.hpp:141
friend size_type erase_if(OrderedMultimap &container, Predicate predicate)
Definition OrderedMultimap.hpp:602
value_compare value_comp() const
Definition OrderedMultimap.hpp:577
const_iterator upper_bound(const Key &key) const noexcept
Definition OrderedMultimap.hpp:564
OrderedMultimap(InputIterator first, Sentinel last, const Compare &compare=Compare(), const Allocator &allocator=Allocator())
Definition OrderedMultimap.hpp:175
iterator erase(const_iterator pos)
Definition OrderedMultimap.hpp:452
constexpr bool operator>(const OrderedMultimap &other) const
Definition OrderedMultimap.hpp:593
value_type * getMutableEnd()
Definition OrderedMultimap.hpp:630
constexpr bool operator<=(const OrderedMultimap &other) const
Definition OrderedMultimap.hpp:589
Pair< const_iterator, const_iterator > equal_range(const Key &key) const noexcept
Definition OrderedMultimap.hpp:526
typename iterator::reference reference
Definition OrderedMultimap.hpp:144
iterator emplace_hint(const_iterator hint, Args &&... args)
Definition OrderedMultimap.hpp:447
size_type eraseN(size_type offset, size_type count)
Definition OrderedMultimap.hpp:671
const_iterator begin() const noexcept
Definition OrderedMultimap.hpp:306
typename const_iterator::reference const_reference
Definition OrderedMultimap.hpp:145
iterator upper_bound(K &&x) noexcept
Definition OrderedMultimap.hpp:560
iterator end() noexcept
Definition OrderedMultimap.hpp:314
typename const_iterator::pointer const_pointer
Definition OrderedMultimap.hpp:147
std::size_t size_type
Definition OrderedMultimap.hpp:31
iterator upper_bound(const Key &key) noexcept
Definition OrderedMultimap.hpp:555
const_iterator upper_bound(K &&x) const noexcept
Definition OrderedMultimap.hpp:569
typename iterator::difference_type difference_type
Definition OrderedMultimap.hpp:143
OrderedMultimap()
Definition OrderedMultimap.hpp:164
bool contains(K &&x) const noexcept
Definition OrderedMultimap.hpp:511
OrderedMultimap & operator=(std::initializer_list< value_type > ilist)
Definition OrderedMultimap.hpp:292
Allocator allocator
Definition OrderedMultimap.hpp:687
const_reverse_iterator rbegin() const noexcept
Definition OrderedMultimap.hpp:330
reverse_iterator rend() noexcept
Definition OrderedMultimap.hpp:338
OrderedMultimap(const Compare &compare, const Allocator &allocator=Allocator())
Definition OrderedMultimap.hpp:167
OrderedMultimap(const OrderedMultimap &other, const Allocator &allocator)
Definition OrderedMultimap.hpp:193
size_type erase(const Key &key)
Definition OrderedMultimap.hpp:460
void insert(InputIterator first, Sentinel last)
Definition OrderedMultimap.hpp:410
OrderedMultimap(const OrderedMultimap &other)
Definition OrderedMultimap.hpp:190
iterator insert(P &&value)
Definition OrderedMultimap.hpp:400
size_type elementCount
Definition OrderedMultimap.hpp:684
void clear() noexcept
Definition OrderedMultimap.hpp:366
OrderedMultimap & operator=(OrderedMultimap &&other) noexcept
Definition OrderedMultimap.hpp:259
friend void swap(OrderedMultimap &a, OrderedMultimap &b) noexcept
Definition OrderedMultimap.hpp:491
OrderedMultimap(std::initializer_list< value_type > ilist, const Allocator &allocator)
Definition OrderedMultimap.hpp:187
size_type size() const noexcept
Definition OrderedMultimap.hpp:354
void popElement()
Definition OrderedMultimap.hpp:653
Pair< iterator, iterator > equal_range(K &&x) noexcept
Definition OrderedMultimap.hpp:521
void reserve(size_type newCapacity)
Definition OrderedMultimap.hpp:373
const_iterator lower_bound(K &&x) const noexcept
Definition OrderedMultimap.hpp:551
void insert_range(R &&r)
Definition OrderedMultimap.hpp:435
T mapped_type
Definition OrderedMultimap.hpp:29
constexpr bool operator<(const OrderedMultimap &other) const
Definition OrderedMultimap.hpp:585
std::reverse_iterator< iterator > reverse_iterator
Definition OrderedMultimap.hpp:140
value_compare compare
Definition OrderedMultimap.hpp:686
const_reverse_iterator crend() const noexcept
Definition OrderedMultimap.hpp:346
const_reverse_iterator crbegin() const noexcept
Definition OrderedMultimap.hpp:334
iterator begin() noexcept
Definition OrderedMultimap.hpp:302
void pushElement(Args &&... args)
Definition OrderedMultimap.hpp:644
void reset() noexcept
Definition OrderedMultimap.hpp:634
OrderedMultimap & operator=(const OrderedMultimap &other)
Definition OrderedMultimap.hpp:232
Iterator< false > iterator
Definition OrderedMultimap.hpp:138
OrderedMultimap(std::initializer_list< value_type > ilist, const Compare &compare=Compare(), const Allocator &allocator=Allocator())
Definition OrderedMultimap.hpp:184
const_iterator end() const noexcept
Definition OrderedMultimap.hpp:318
std::allocator_traits< Allocator >::pointer elements
Definition OrderedMultimap.hpp:683
~OrderedMultimap()
Definition OrderedMultimap.hpp:228
Definition concepts.hpp:106
Definition Allocation.hpp:554
grem::OrderedMultimap< Key, T, Compare, std::pmr::polymorphic_allocator< Pair< Key, T > > > OrderedMultimap
Definition OrderedMultimap.hpp:695
Definition aliases.hpp:9
constexpr auto move(input_range auto &&range, auto outputIterator)
Definition algorithms.hpp:669
Definition OrderedMultimap.hpp:611
bool operator()(const auto &a, const auto &b) const
Definition OrderedMultimap.hpp:612
Compare comp
Definition OrderedMultimap.hpp:623
Definition OrderedMultimap.hpp:46
reference ref
Definition OrderedMultimap.hpp:47
constexpr reference * operator->() noexcept
Definition OrderedMultimap.hpp:49
Definition Pair.hpp:53
T2 second
Definition Pair.hpp:58
T1 first
Definition Pair.hpp:57