12 template<
typename Key,
typename Value,
typename Container>
class BasicIndexedMultimap :
private Container {
44 using super::equal_range;
45 using super::lower_bound;
46 using super::upper_bound;
49 using super::contains;
63 template<
typename K = Key>
auto values(
const K&
key)
const {
91 throw std::out_of_range(
"key");
95 throw std::out_of_range(
"index");
104 template<
typename K = Key>
bool contains(
const K&
key,
size_t index)
const {
return super::count(
key) > index; }
131 super::shrink_to_fit();
166 return super::capacity();
186 throw std::out_of_range(
"index");
190 throw std::out_of_range(
"index");
201 return super::emplace_hint(
upper_bound(
key), std::piecewise_construct, std::forward_as_tuple(
key), std::forward_as_tuple(args...))->second;
219 return at(
key, index);
236 template<
typename Key,
typename Value,
typename Compare = std::less<>,
typename RawAllocator = DefaultAllocator>
241 template<
typename Key,
typename Value,
size_t N,
typename Compare = std::less<>,
typename RawAllocator = DefaultAllocator>
246template<
typename Key,
typename Value,
typename Container>
struct std::hash<
CeresEngine::BasicIndexedMultimap<Key, Value, Container>> {
248 [[nodiscard]]
size_t operator()(
const ValueType& value) {
return std::hash<Container>{}(value); }
Definition IndexedMultimap.hpp:12
typename super::difference_type difference_type
Definition IndexedMultimap.hpp:20
typename super::key_compare key_compare
Definition IndexedMultimap.hpp:21
void clear(const K &key)
Clears all values of the given key.
Definition IndexedMultimap.hpp:156
size_type capacity() const
Returns the number of elements that the container has currently allocated space for.
Definition IndexedMultimap.hpp:164
const mapped_type & at(const K &key, size_t index) const
Gets the index-th value for the given key.
Definition IndexedMultimap.hpp:85
typename super::value_type value_type
Definition IndexedMultimap.hpp:18
Container super
Definition IndexedMultimap.hpp:13
auto keys() const
Gets a range that iterates over all the keys on the map.
Definition IndexedMultimap.hpp:57
typename super::mapped_type mapped_type
Definition IndexedMultimap.hpp:17
static constexpr bool has_capacity
Determines if the container has the capacity() method available.
Definition IndexedMultimap.hpp:159
mapped_type & emplace_back(const K &key, Args &&... args)
Emplaces a new element for key at the end of container.
Definition IndexedMultimap.hpp:200
mapped_type & operator()(const K &key, size_type index)
Definition IndexedMultimap.hpp:217
typename super::const_pointer const_pointer
Definition IndexedMultimap.hpp:26
auto values(const Key &key)
Gets a range that iterates over all values of the given key.
Definition IndexedMultimap.hpp:69
bool contains(const K &key, size_t index) const
Returns true if the container contains an element at index with key equivalent to key,...
Definition IndexedMultimap.hpp:104
size_type size(const K &key) const
Computes the number of elements for the given key.
Definition IndexedMultimap.hpp:172
typename super::pointer pointer
Definition IndexedMultimap.hpp:25
mapped_type & push_back(const K &key, Value &&value)
Pushes a new element for key at the end of container.
Definition IndexedMultimap.hpp:211
typename super::reference reference
Definition IndexedMultimap.hpp:23
const mapped_type & operator()(const K &key, size_type index) const
Definition IndexedMultimap.hpp:215
static constexpr bool has_reserve
Determines if the container has the reserve() method available.
Definition IndexedMultimap.hpp:107
mapped_type & push_back(const K &key, const Value &value)
Pushes a new element for key at the end of container.
Definition IndexedMultimap.hpp:208
mapped_type & at(const K &key, size_t index)
Gets the index-th value for the given key.
Definition IndexedMultimap.hpp:82
auto values(const K &key) const
Gets a range that iterates over all values of the given key.
Definition IndexedMultimap.hpp:63
typename super::key_type key_type
Definition IndexedMultimap.hpp:16
typename super::reverse_iterator reverse_iterator
Definition IndexedMultimap.hpp:29
void shrink_to_fit()
Tries to reduce memory usage by freeing unused memory.
Definition IndexedMultimap.hpp:129
void reserve(size_type newCapacity)
Tries to increase capacity by allocating additional memory.
Definition IndexedMultimap.hpp:120
typename super::const_iterator const_iterator
Definition IndexedMultimap.hpp:28
typename super::size_type size_type
Definition IndexedMultimap.hpp:19
typename super::const_reference const_reference
Definition IndexedMultimap.hpp:24
typename super::iterator iterator
Definition IndexedMultimap.hpp:27
void resize(const K &key, size_type newSize, const Value &value=Value())
Resizes the container and ensures that there are exactly newSize items on the given key.
Definition IndexedMultimap.hpp:140
typename super::allocator_type allocator_type
Definition IndexedMultimap.hpp:22
iterator erase(const K &key, size_type index) const
Erases the element at the given index for the given key.
Definition IndexedMultimap.hpp:180
typename super::const_reverse_iterator const_reverse_iterator
Definition IndexedMultimap.hpp:30
static constexpr bool has_shrink_to_fit
Determines if the container has the shrink_to_fit() method available.
Definition IndexedMultimap.hpp:126
void ensureSize(const K &key, size_type desiredSize)
Ensures that the vector has a size of at least desiredSize on the given key.
Definition IndexedMultimap.hpp:226
Definition Application.hpp:19
auto range()
Returns an iterator that increases it's value from 0 to end by 1 for each step.
Definition Iterator.hpp:350
auto values(Container &container)
Returns an iterable object that iterates over the values of a map-like container.
Definition Iterator.hpp:400
auto wrap(IB &&a, IE &&b, Context &&context)
Wraps two iterators into a single-use container with begin/end methods to match the C++ iterator conv...
Definition Iterator.hpp:296
auto keys(Container &container)
Returns an iterable object that iterates over the keys of a map-like container.
Definition Iterator.hpp:380
@ Key
The event is of type KeyEvent.
auto unique(Container &container)
Returns an iterable object that iterates over all unique values on the container.
Definition Iterator.hpp:473
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25