Ion
|
This template class can be used to map between two kinds of indices when the following assumptions apply: More...
#include "indexmap.h"
Public Member Functions | |
IndexMap (const UnorderedIndexType unordered_indices[], size_t count) | |
The map is initialized with an array of N UnorderedIndexType values that directly correspond to a 0-based array of OrderedIndexType, in the same order. More... | |
size_t | GetCount () const |
Returns the count passed to the constructor. More... | |
UnorderedIndexType | GetUnorderedIndex (OrderedIndexType ordered_index) const |
Returns the UnorderedIndexType corresponding to the given OrderedIndexType value. More... | |
OrderedIndexType | GetOrderedIndex (UnorderedIndexType unordered_index) const |
Returns the OrderedIndexType corresponding to the given UnorderedIndexType value. More... | |
This template class can be used to map between two kinds of indices when the following assumptions apply:
Mapping from an OrderedIndexType to an UnorderedIndexType is constant-time, while mapping the other way around is linear.
This class is very light-weight and is intended to be constructed as a temporary variable when needed.
Definition at line 40 of file indexmap.h.
|
inline |
The map is initialized with an array of N UnorderedIndexType values that directly correspond to a 0-based array of OrderedIndexType, in the same order.
It is assumed that the lifetime of the passed array is at least as long as the IndexMap instance's, since the IndexMap does not copy the array values.
Definition at line 47 of file indexmap.h.
|
inline |
Returns the count passed to the constructor.
Definition at line 52 of file indexmap.h.
|
inline |
Returns the OrderedIndexType corresponding to the given UnorderedIndexType value.
This is a linear-time operation. This will DCHECK if the index is not found.
Definition at line 65 of file indexmap.h.
|
inline |
Returns the UnorderedIndexType corresponding to the given OrderedIndexType value.
This is a constant-time operation.
Definition at line 56 of file indexmap.h.