Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Core::Utils::IndexMap< T > Class Template Reference

#include <Core/Utils/IndexMap.hpp>

+ Inheritance diagram for Ra::Core::Utils::IndexMap< T >:
+ Collaboration diagram for Ra::Core::Utils::IndexMap< T >:

Public Types

using Container = typename std::deque<T>
 
using IndexContainer = typename std::deque<Index>
 Where the objects are stored.
 
using ConstIndexIterator
 Where the indices are stored.
 
using Iterator
 
using ConstIterator = typename Container::const_iterator
 Iterator to the list of objects of the IndexMap.
 

Public Member Functions

 IndexMap ()
 
 IndexMap (const IndexMap &id_map)
 Default constructor.
 
 ~IndexMap ()
 Copy constructor.
 
Index insert (const T &obj)
 Destructor.
 
template<typename... Args>
Index emplace (const Args &&... args)
 
bool remove (const Index &idx)
 Remove the object with the given index. Return false if the operation failed.
 
const T & at (const Index &idx) const
 Return a read-only ref to object with the given index. Crashes if index does not exist.
 
T & access (const Index &idx)
 Return a reference to the object with the given index. Crash if index does not exist.
 
size_t size () const
 
void clear ()
 Return the size of the IndexMap ( number of object contained ).
 
bool empty () const
 Clear the IndexMap.
 
bool full () const
 Return true if the IndexMap is empty.
 
bool contains (const Index &idx) const
 Return true if the IndexMap cannot contain more objects.
 
Index index (const uint i) const
 Return true if the IndexMap contains a object with the given index.
 
T & operator[] (const Index &idx)
 Return the i-th index. Return an invalid index if i is out of bound.
 
const T & operator[] (const Index &idx) const
 Return a reference to the object with given index.
 
ConstIndexIterator cbegin_index () const
 Return a const reference to the object with given index.
 
ConstIndexIterator cend_index () const
 Return a const iterator to the first index in the IndexMap.
 
Iterator begin ()
 Return a const iterator to the end of the indices of the IndexMap.
 
Iterator end ()
 Return a iterator to the first object in the IndexMap.
 
ConstIterator begin () const
 Return a iterator to the end of the object list in the IndexMap.
 
ConstIterator end () const
 Return a iterator to the first object in the IndexMap.
 
ConstIterator cbegin () const
 Return a iterator to the end of the object list in the IndexMap.
 
ConstIterator cend () const
 Return a const iterator to the first object in the IndexMap.
 

Protected Attributes

Container m_data
 Return a const iterator to the end of the object list in the IndexMap.
 
IndexContainer m_index
 Objects in the IndexMap.
 

Detailed Description

template<typename T>
class Ra::Core::Utils::IndexMap< T >

The class IndexMap define a map where a object is coupled with a index. The index is unique, it is assigned to a object when it's inserted and is kept until the object is removed. After a removal, the index becomes free again. A object will be given the first free index available. If no free indices are available, the object will not be inserted and the IndexMap is considered full.

Definition at line 23 of file IndexMap.hpp.

Member Typedef Documentation

◆ ConstIndexIterator

template<typename T >
using Ra::Core::Utils::IndexMap< T >::ConstIndexIterator
Initial value:
typename IndexContainer::const_iterator

Where the indices are stored.

Definition at line 32 of file IndexMap.hpp.

◆ ConstIterator

template<typename T >
using Ra::Core::Utils::IndexMap< T >::ConstIterator = typename Container::const_iterator

Iterator to the list of objects of the IndexMap.

Definition at line 37 of file IndexMap.hpp.

◆ Container

template<typename T >
using Ra::Core::Utils::IndexMap< T >::Container = typename std::deque<T>

Definition at line 29 of file IndexMap.hpp.

◆ IndexContainer

template<typename T >
using Ra::Core::Utils::IndexMap< T >::IndexContainer = typename std::deque<Index>

Where the objects are stored.

Definition at line 30 of file IndexMap.hpp.

◆ Iterator

template<typename T >
using Ra::Core::Utils::IndexMap< T >::Iterator
Initial value:
typename Container::iterator

Const iterator to the list of indices of the IndexMap.

Definition at line 35 of file IndexMap.hpp.

Constructor & Destructor Documentation

◆ IndexMap() [1/2]

template<typename T >
Ra::Core::Utils::IndexMap< T >::IndexMap ( )
inline

Const iterator to the list of objects of the IndexMap.

Definition at line 154 of file IndexMap.hpp.

◆ IndexMap() [2/2]

template<typename T >
Ra::Core::Utils::IndexMap< T >::IndexMap ( const IndexMap< T > & id_map)
inline

Default constructor.

Definition at line 157 of file IndexMap.hpp.

◆ ~IndexMap()

template<typename T >
Ra::Core::Utils::IndexMap< T >::~IndexMap ( )
inline

Copy constructor.

Definition at line 164 of file IndexMap.hpp.

Member Function Documentation

◆ access()

template<typename T >
T & Ra::Core::Utils::IndexMap< T >::access ( const Index & idx)
inline

Return a reference to the object with the given index. Crash if index does not exist.

Definition at line 221 of file IndexMap.hpp.

+ Here is the call graph for this function:

◆ at()

template<typename T >
const T & Ra::Core::Utils::IndexMap< T >::at ( const Index & idx) const
inline

Return a read-only ref to object with the given index. Crashes if index does not exist.

Definition at line 213 of file IndexMap.hpp.

+ Here is the call graph for this function:

◆ begin() [1/2]

template<typename T >
IndexMap< T >::Iterator Ra::Core::Utils::IndexMap< T >::begin ( )
inline

Return a const iterator to the end of the indices of the IndexMap.

Definition at line 299 of file IndexMap.hpp.

◆ begin() [2/2]

template<typename T >
IndexMap< T >::ConstIterator Ra::Core::Utils::IndexMap< T >::begin ( ) const
inline

Return a iterator to the end of the object list in the IndexMap.

Definition at line 309 of file IndexMap.hpp.

◆ cbegin()

template<typename T >
IndexMap< T >::ConstIterator Ra::Core::Utils::IndexMap< T >::cbegin ( ) const
inline

Return a iterator to the end of the object list in the IndexMap.

Definition at line 319 of file IndexMap.hpp.

◆ cbegin_index()

template<typename T >
IndexMap< T >::ConstIndexIterator Ra::Core::Utils::IndexMap< T >::cbegin_index ( ) const
inline

Return a const reference to the object with given index.

Definition at line 286 of file IndexMap.hpp.

◆ cend()

template<typename T >
IndexMap< T >::ConstIterator Ra::Core::Utils::IndexMap< T >::cend ( ) const
inline

Return a const iterator to the first object in the IndexMap.

Definition at line 324 of file IndexMap.hpp.

◆ cend_index()

template<typename T >
IndexMap< T >::ConstIndexIterator Ra::Core::Utils::IndexMap< T >::cend_index ( ) const
inline

Return a const iterator to the first index in the IndexMap.

Definition at line 291 of file IndexMap.hpp.

◆ clear()

template<typename T >
void Ra::Core::Utils::IndexMap< T >::clear ( )
inline

Return the size of the IndexMap ( number of object contained ).

Definition at line 236 of file IndexMap.hpp.

◆ contains()

template<typename T >
bool Ra::Core::Utils::IndexMap< T >::contains ( const Index & idx) const
inline

Return true if the IndexMap cannot contain more objects.

Definition at line 257 of file IndexMap.hpp.

+ Here is the call graph for this function:

◆ emplace()

template<typename T >
template<typename... Args>
Index Ra::Core::Utils::IndexMap< T >::emplace ( const Args &&... args)
inline

Construct an object in place in the IndexMap. Return an invalid index if the object is not inserted.

Definition at line 184 of file IndexMap.hpp.

+ Here is the call graph for this function:

◆ empty()

template<typename T >
bool Ra::Core::Utils::IndexMap< T >::empty ( ) const
inline

Clear the IndexMap.

Definition at line 247 of file IndexMap.hpp.

◆ end() [1/2]

template<typename T >
IndexMap< T >::Iterator Ra::Core::Utils::IndexMap< T >::end ( )
inline

Return a iterator to the first object in the IndexMap.

Definition at line 304 of file IndexMap.hpp.

◆ end() [2/2]

template<typename T >
IndexMap< T >::ConstIterator Ra::Core::Utils::IndexMap< T >::end ( ) const
inline

Return a iterator to the first object in the IndexMap.

Definition at line 314 of file IndexMap.hpp.

◆ full()

template<typename T >
bool Ra::Core::Utils::IndexMap< T >::full ( ) const
inline

Return true if the IndexMap is empty.

Definition at line 252 of file IndexMap.hpp.

◆ index()

template<typename T >
Index Ra::Core::Utils::IndexMap< T >::index ( const uint i) const
inline

Return true if the IndexMap contains a object with the given index.

Definition at line 264 of file IndexMap.hpp.

◆ insert()

template<typename T >
Index Ra::Core::Utils::IndexMap< T >::insert ( const T & obj)
inline

Destructor.

Insert a object in the IndexMap. Return an invalid index if the object is not inserted.

Definition at line 170 of file IndexMap.hpp.

+ Here is the call graph for this function:

◆ operator[]() [1/2]

template<typename T >
T & Ra::Core::Utils::IndexMap< T >::operator[] ( const Index & idx)
inline

Return the i-th index. Return an invalid index if i is out of bound.

Definition at line 273 of file IndexMap.hpp.

◆ operator[]() [2/2]

template<typename T >
const T & Ra::Core::Utils::IndexMap< T >::operator[] ( const Index & idx) const
inline

Return a reference to the object with given index.

Definition at line 278 of file IndexMap.hpp.

◆ remove()

template<typename T >
bool Ra::Core::Utils::IndexMap< T >::remove ( const Index & idx)
inline

Remove the object with the given index. Return false if the operation failed.

Definition at line 200 of file IndexMap.hpp.

+ Here is the call graph for this function:

◆ size()

template<typename T >
size_t Ra::Core::Utils::IndexMap< T >::size ( ) const
inline

Definition at line 231 of file IndexMap.hpp.

Member Data Documentation

◆ m_data

template<typename T >
Container Ra::Core::Utils::IndexMap< T >::m_data
protected

Return a const iterator to the end of the object list in the IndexMap.

Definition at line 123 of file IndexMap.hpp.

◆ m_index

template<typename T >
IndexContainer Ra::Core::Utils::IndexMap< T >::m_index
protected

Objects in the IndexMap.

Definition at line 124 of file IndexMap.hpp.


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