Celeritas  0.5.0-86+4a8eea4
Public Member Functions | List of all members
celeritas::CollectionBuilder< T, M, I > Class Template Reference

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.
 

Detailed Description

template<class T, MemSpace M = MemSpace::host, class I = ItemId<T>>
class celeritas::CollectionBuilder< T, M, I >

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.

auto cb = make_builder(&myintcol.host);
cb.reserve(100);
ItemRange<int> insertion
= cb.insert_back(local_ints.begin(), local_ints.end());
cb.push_back(123);
CollectionBuilder< T, M, I > make_builder(Collection< T, Ownership::value, M, I > *collection)
Helper function for constructing collection builders.
Definition: CollectionBuilder.hh:196

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.)


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