CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::BasicIndexedMultimap< Key, Value, Container > Class Template Reference

#include <CeresEngine/Foundation/Container/IndexedMultimap.hpp>

Inheritance diagram for CeresEngine::BasicIndexedMultimap< Key, Value, Container >:
CeresEngine::GPUResourceSetBindings CeresEngine::GPUShaderResourceSetBindings

Public Types

using key_type = typename super::key_type
 
using mapped_type = typename super::mapped_type
 
using value_type = typename super::value_type
 
using size_type = typename super::size_type
 
using difference_type = typename super::difference_type
 
using key_compare = typename super::key_compare
 
using allocator_type = typename super::allocator_type
 
using reference = typename super::reference
 
using const_reference = typename super::const_reference
 
using pointer = typename super::pointer
 
using const_pointer = typename super::const_pointer
 
using iterator = typename super::iterator
 
using const_iterator = typename super::const_iterator
 
using reverse_iterator = typename super::reverse_iterator
 
using const_reverse_iterator = typename super::const_reverse_iterator
 

Public Member Functions

auto keys () const
 Gets a range that iterates over all the keys on the map.
 
template<typename K = Key>
auto values (const K &key) const
 Gets a range that iterates over all values of the given key.
 
template<typename K = Key>
auto values (const Key &key)
 Gets a range that iterates over all values of the given key.
 
template<typename K = Key>
mapped_typeat (const K &key, size_t index)
 Gets the index-th value for the given key.
 
template<typename K = Key>
const mapped_typeat (const K &key, size_t index) const
 Gets the index-th value for the given key.
 
template<typename K = Key>
bool contains (const K &key, size_t index) const
 Returns true if the container contains an element at index with key equivalent to key, otherwise returns false.
 
void reserve (size_type newCapacity)
 Tries to increase capacity by allocating additional memory.
 
void shrink_to_fit ()
 Tries to reduce memory usage by freeing unused memory.
 
template<typename K = Key>
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.
 
template<typename K = Key>
void clear (const K &key)
 Clears all values of the given key.
 
size_type capacity () const
 Returns the number of elements that the container has currently allocated space for.
 
template<typename K = Key>
size_type size (const K &key) const
 Computes the number of elements for the given key.
 
template<typename K = Key>
iterator erase (const K &key, size_type index) const
 Erases the element at the given index for the given key.
 
template<typename K = Key, typename... Args>
mapped_typeemplace_back (const K &key, Args &&... args)
 Emplaces a new element for key at the end of container.
 
template<typename K = Key>
mapped_typepush_back (const K &key, const Value &value)
 Pushes a new element for key at the end of container.
 
template<typename K = Key>
mapped_typepush_back (const K &key, Value &&value)
 Pushes a new element for key at the end of container.
 
template<typename K = Key>
const mapped_typeoperator() (const K &key, size_type index) const
 
template<typename K = Key>
mapped_typeoperator() (const K &key, size_type index)
 

Static Public Attributes

static constexpr bool has_reserve = requires(super & container) { container.reserve(size_type()); }
 Determines if the container has the reserve() method available.
 
static constexpr bool has_shrink_to_fit = requires(super & container) { container.shrink_to_fit(); }
 Determines if the container has the shrink_to_fit() method available.
 
static constexpr bool has_capacity
 Determines if the container has the capacity() method available.
 

Private Types

using super = Container
 

Private Member Functions

template<typename K = Key>
void ensureSize (const K &key, size_type desiredSize)
 Ensures that the vector has a size of at least desiredSize on the given key.
 

Member Typedef Documentation

◆ allocator_type

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::allocator_type = typename super::allocator_type

◆ const_iterator

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::const_iterator = typename super::const_iterator

◆ const_pointer

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::const_pointer = typename super::const_pointer

◆ const_reference

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::const_reference = typename super::const_reference

◆ const_reverse_iterator

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::const_reverse_iterator = typename super::const_reverse_iterator

◆ difference_type

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::difference_type = typename super::difference_type

◆ iterator

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::iterator = typename super::iterator

◆ key_compare

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::key_compare = typename super::key_compare

◆ key_type

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::key_type = typename super::key_type

◆ mapped_type

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::mapped_type = typename super::mapped_type

◆ pointer

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::pointer = typename super::pointer

◆ reference

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::reference = typename super::reference

◆ reverse_iterator

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::reverse_iterator = typename super::reverse_iterator

◆ size_type

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::size_type = typename super::size_type

◆ super

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::super = Container
private

◆ value_type

template<typename Key , typename Value , typename Container >
using CeresEngine::BasicIndexedMultimap< Key, Value, Container >::value_type = typename super::value_type

Member Function Documentation

◆ at() [1/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
mapped_type & CeresEngine::BasicIndexedMultimap< Key, Value, Container >::at ( const K key,
size_t  index 
)
inline

Gets the index-th value for the given key.

Parameters
keyThe key to get the specified element at.
indexThe index of the element to be fetched.
Returns
A reference to the element at (key, index).
Exceptions
std::out_of_rangeif the container does not have an element with the specified key.
std::out_of_rangeif !(index < size(key)).

◆ at() [2/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
const mapped_type & CeresEngine::BasicIndexedMultimap< Key, Value, Container >::at ( const K key,
size_t  index 
) const
inline

Gets the index-th value for the given key.

Parameters
keyThe key to get the specified element at.
indexThe index of the element to be fetched.
Returns
A reference to the element at (key, index).
Exceptions
std::out_of_rangeif the container does not have an element with the specified key.
std::out_of_rangeif !(index < size(key)).

◆ capacity()

template<typename Key , typename Value , typename Container >
size_type CeresEngine::BasicIndexedMultimap< Key, Value, Container >::capacity ( ) const
inline

Returns the number of elements that the container has currently allocated space for.

◆ clear()

template<typename Key , typename Value , typename Container >
template<typename K = Key>
void CeresEngine::BasicIndexedMultimap< Key, Value, Container >::clear ( const K key)
inline

Clears all values of the given key.

◆ contains()

template<typename Key , typename Value , typename Container >
template<typename K = Key>
bool CeresEngine::BasicIndexedMultimap< Key, Value, Container >::contains ( const K key,
size_t  index 
) const
inline

Returns true if the container contains an element at index with key equivalent to key, otherwise returns false.

◆ emplace_back()

template<typename Key , typename Value , typename Container >
template<typename K = Key, typename... Args>
mapped_type & CeresEngine::BasicIndexedMultimap< Key, Value, Container >::emplace_back ( const K key,
Args &&...  args 
)
inline

Emplaces a new element for key at the end of container.

Parameters
keyThe key to insert the element at.
argsThe arguments to construct a new value with.
Returns
A reference to the newly emplaced value.

◆ ensureSize()

template<typename Key , typename Value , typename Container >
template<typename K = Key>
void CeresEngine::BasicIndexedMultimap< Key, Value, Container >::ensureSize ( const K key,
size_type  desiredSize 
)
inlineprivate

Ensures that the vector has a size of at least desiredSize on the given key.

Parameters
keyThe key to ensure the number of elements on.
desiredSizeThe number of elements to ensure are present on key.

◆ erase()

template<typename Key , typename Value , typename Container >
template<typename K = Key>
iterator CeresEngine::BasicIndexedMultimap< Key, Value, Container >::erase ( const K key,
size_type  index 
) const
inline

Erases the element at the given index for the given key.

Parameters
keyThe key to remove the element at.
indexThe index to remove the element at.
Exceptions
std::out_of_rangeif the container does not have an element with the specified key.
std::out_of_rangeif !(index < size(key)).

◆ keys()

template<typename Key , typename Value , typename Container >
auto CeresEngine::BasicIndexedMultimap< Key, Value, Container >::keys ( ) const
inline

Gets a range that iterates over all the keys on the map.

Each key will only be iterated once, no matter how many values it has.

◆ operator()() [1/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
mapped_type & CeresEngine::BasicIndexedMultimap< Key, Value, Container >::operator() ( const K key,
size_type  index 
)
inline

◆ operator()() [2/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
const mapped_type & CeresEngine::BasicIndexedMultimap< Key, Value, Container >::operator() ( const K key,
size_type  index 
) const
inline

◆ push_back() [1/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
mapped_type & CeresEngine::BasicIndexedMultimap< Key, Value, Container >::push_back ( const K key,
const Value &  value 
)
inline

Pushes a new element for key at the end of container.

Parameters
keyThe key to insert the element at.
valueThe value to be inserted on the container.
Returns
A reference to the newly constructed value.

◆ push_back() [2/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
mapped_type & CeresEngine::BasicIndexedMultimap< Key, Value, Container >::push_back ( const K key,
Value &&  value 
)
inline

Pushes a new element for key at the end of container.

Parameters
keyThe key to insert the element at.
valueThe value to be inserted on the container.
Returns
A reference to the newly constructed value.

◆ reserve()

template<typename Key , typename Value , typename Container >
void CeresEngine::BasicIndexedMultimap< Key, Value, Container >::reserve ( size_type  newCapacity)
inline

Tries to increase capacity by allocating additional memory.

If newCapacity > capacity(), the function allocates memory for new storage of capacity equal to the value of newCapacity, moves elements from old storage to new storage, and deallocates memory used by old storage. Otherwise the function does nothing.

This function does not change size of the container.

If the capacity is changed, all iterators and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.

◆ resize()

template<typename Key , typename Value , typename Container >
template<typename K = Key>
void CeresEngine::BasicIndexedMultimap< Key, Value, Container >::resize ( const K key,
size_type  newSize,
const Value &  value = Value() 
)
inline

Resizes the container and ensures that there are exactly newSize items on the given key.

If any new value must be created on the map, they will be initialized by constructing a copy of value.

Parameters
keyThe key to resize the elements on.
newSizeThe new size to set on the key.
valueThe value to initialize any new value with.

◆ shrink_to_fit()

template<typename Key , typename Value , typename Container >
void CeresEngine::BasicIndexedMultimap< Key, Value, Container >::shrink_to_fit ( )
inline

Tries to reduce memory usage by freeing unused memory.

◆ size()

template<typename Key , typename Value , typename Container >
template<typename K = Key>
size_type CeresEngine::BasicIndexedMultimap< Key, Value, Container >::size ( const K key) const
inline

Computes the number of elements for the given key.

Returns
The number of elements for the given key. Can be 0 if there is no such key on the map.

◆ values() [1/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
auto CeresEngine::BasicIndexedMultimap< Key, Value, Container >::values ( const K key) const
inline

Gets a range that iterates over all values of the given key.

◆ values() [2/2]

template<typename Key , typename Value , typename Container >
template<typename K = Key>
auto CeresEngine::BasicIndexedMultimap< Key, Value, Container >::values ( const Key key)
inline

Gets a range that iterates over all values of the given key.

Member Data Documentation

◆ has_capacity

template<typename Key , typename Value , typename Container >
constexpr bool CeresEngine::BasicIndexedMultimap< Key, Value, Container >::has_capacity
staticconstexpr
Initial value:
= requires(const super& container) {
{ container.capacity() } -> std::template same_as<size_type>;
}
Container super
Definition IndexedMultimap.hpp:13
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25

Determines if the container has the capacity() method available.

◆ has_reserve

template<typename Key , typename Value , typename Container >
constexpr bool CeresEngine::BasicIndexedMultimap< Key, Value, Container >::has_reserve = requires(super & container) { container.reserve(size_type()); }
staticconstexpr

Determines if the container has the reserve() method available.

◆ has_shrink_to_fit

template<typename Key , typename Value , typename Container >
constexpr bool CeresEngine::BasicIndexedMultimap< Key, Value, Container >::has_shrink_to_fit = requires(super & container) { container.shrink_to_fit(); }
staticconstexpr

Determines if the container has the shrink_to_fit() method available.


The documentation for this class was generated from the following file: