Celeritas 0.7.0-dev.79+develop.b3dc2e108
|
Access data in a Range<T2> with an index of type T1. More...
#include <Collection.hh>
Public Types | |
Type aliases | |
using | key_type = T1 |
using | mapped_type = T2 |
Public Member Functions | |
CELER_FUNCTION | ItemMap (Range< T2 > range) |
Construct implicitly from an existing Range<T2> | |
CELER_FUNCTION | ItemMap (T2 start, T2 stop) |
Construct like a range. | |
CELER_FORCEINLINE_FUNCTION T2 | operator[] (T1 id) const |
Access Range via OpaqueId of type T1. | |
CELER_FORCEINLINE_FUNCTION bool | empty () const |
Whether the underlying Range<T2> is empty. | |
CELER_FORCEINLINE_FUNCTION size_type | size () const |
Size of the underlying Range<T2> | |
Access data in a Range<T2> with an index of type T1.
Here, T1 and T2 are expected to be OpaqueId types. This is simply a type-safe "offset" with range checking.
Example:
Here, components
semantically refers to a contiguous range of real values in the doubles
collection, where ElComponentId{0}
is the first value in that range. Dereferencing the value requires using the map alongside the backend storage:
Note that this access requires only two indirections, as ItemMap
is merely performing integer arithmetic.