![]() |
Radium Engine
1.5.0
|
#include <Core/Utils/IndexMap.hpp>
Public Types | |
using | Container = typename std::deque< T > |
using | IndexContainer = typename std::deque< Index > |
Where the objects are stored. | |
using | ConstIndexIterator = typename IndexContainer::const_iterator |
Where the indices are stored. | |
using | Iterator = typename Container::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. More... | |
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. | |
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.
using Ra::Core::Utils::IndexMap< T >::Iterator = typename Container::iterator |
Const iterator to the list of indices of the IndexMap.
Definition at line 35 of file IndexMap.hpp.
|
inline |
Const iterator to the list of objects of the IndexMap.
Definition at line 154 of file IndexMap.hpp.
|
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.
|
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.