Celeritas
0.5.0-86+4a8eea4
|
Helper class for constructing Collection objects. More...
#include <CollectionBuilder.hh>
Public Types | |
Type aliases | |
using | CollectionT = Collection< T, Ownership::value, M, I > |
using | value_type = T |
using | size_type = typename CollectionT::size_type |
using | ItemIdT = typename CollectionT::ItemIdT |
using | ItemRangeT = typename CollectionT::ItemRangeT |
Public Member Functions | |
CollectionBuilder (CollectionT *collection) | |
Construct from a collection. | |
void | resize (std::size_t count) |
Increase the size to the given number of elements. | |
void | reserve (std::size_t count) |
Reserve space for the given number of elements. | |
template<class InputIterator > | |
ItemRangeT | insert_back (InputIterator first, InputIterator last) |
ItemRangeT | insert_back (std::initializer_list< value_type > init) |
Insert the given list of elements at the end of the allocation. | |
ItemIdT | push_back (value_type const &element) |
Add a new element to the end of the allocation. | |
size_type | size () const |
Number of elements in the collection. | |
ItemIdT | size_id () const |
Get the size as an ID type. | |
template<class InputIterator > | |
auto | insert_back (InputIterator first, InputIterator last) -> ItemRangeT |
Insert the given elements at the end of the allocation. | |
Helper class for constructing Collection objects.
This is intended for use with host data but can also be used to resize device collections. It's constructed with a reference to the host collection, and it provides vector-like methods for extending it. The size cannot be decreased because that would invalidate previously created ItemRange
items.
The CollectionBuilder can also be used to resize device-value collections without having to allocate a host version and copy to device. (This is useful for state allocations.) When resizing values with debugging assertions enabled on host memory, it will assign garbage values to aid in reproducible debugging.)