EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
EBGeometry::PODVector< T > Struct Template Reference

Placement-independent descriptor of a POD array inside a Pool. More...

#include <EBGeometry_PODVector.hpp>

Inheritance diagram for EBGeometry::PODVector< T >:
Inheritance graph
[legend]

Public Member Functions

void reserveFrom (Pool &a_pool, uint32_t a_capacity)
 Reserve a_capacity slots from a_pool, aligned to alignof(T).
 
T * data (void *a_base) const noexcept
 Mutable pointer to element 0 against a_base.
 
const T * data (const void *a_base) const noexcept
 Const pointer to element 0 against a_base.
 
T & at (void *a_base, uint32_t a_i) const noexcept
 Mutable element access against a_base.
 
const T & at (const void *a_base, uint32_t a_i) const noexcept
 Const element access against a_base.
 
uint32_t size () const noexcept
 Number of constructed elements.
 
uint64_t endByte () const noexcept
 One past the last byte this array occupies, measured from the pool base.
 
bool empty () const noexcept
 Whether the array is empty.
 
void push_back (void *a_base, const T &a_value)
 Append one element into the pre-reserved capacity.
 
void assign (void *a_base, const T *a_src, uint32_t a_count)
 Bulk-fill the array from a contiguous host source.
 
PODSpan< T > bind (void *a_base) const noexcept
 Bind a mutable raw-pointer view for a hot loop.
 
PODSpan< const T > bind (const void *a_base) const noexcept
 Bind a const raw-pointer view for a hot loop.
 

Public Attributes

uint64_t m_offset = 0
 Byte offset of element 0 from Pool::base.
 
uint32_t m_size = 0
 Number of constructed elements.
 
uint32_t m_capacity = 0
 Reserved element slots (fixed after reserveFrom; never reallocates).
 

Detailed Description

template<class T>
struct EBGeometry::PODVector< T >

Placement-independent descriptor of a POD array inside a Pool.

Stores a byte offset (not a pointer) plus element size and capacity, so the same value resolves against any pool base – the key to zero-patch host-to-device mirroring. Trivially copyable and exactly 16 bytes.

Template Parameters
TElement type (must be trivially copyable, since it is device-visible storage).

Member Function Documentation

◆ assign()

template<class T >
void EBGeometry::PODVector< T >::assign ( void *  a_base,
const T *  a_src,
uint32_t  a_count 
)
inline

Bulk-fill the array from a contiguous host source.

Copies a_count elements and sets m_size to a_count. A host build-phase operation (the finalize path).

Parameters
[in]a_baseBase address of the pool holding this array.
[in]a_srcSource array of at least a_count elements.
[in]a_countNumber of elements to copy (must be <= m_capacity; aborts otherwise, in every build).

◆ at() [1/2]

template<class T >
const T & EBGeometry::PODVector< T >::at ( const void *  a_base,
uint32_t  a_i 
) const
inlinenoexcept

Const element access against a_base.

Parameters
[in]a_baseBase address of the pool holding this array.
[in]a_iElement index (must be < m_size).
Returns
Const reference to element a_i.

◆ at() [2/2]

template<class T >
T & EBGeometry::PODVector< T >::at ( void *  a_base,
uint32_t  a_i 
) const
inlinenoexcept

Mutable element access against a_base.

Parameters
[in]a_baseBase address of the pool holding this array.
[in]a_iElement index (must be < m_size).
Returns
Reference to element a_i.

◆ bind() [1/2]

template<class T >
PODSpan< const T > EBGeometry::PODVector< T >::bind ( const void *  a_base) const
inlinenoexcept

Bind a const raw-pointer view for a hot loop.

The span must not outlive the next reserve on the pool; see PODSpan.

Parameters
[in]a_baseCurrent base address of the pool holding this array.
Returns
A PODSpan of const elements over the array.

◆ bind() [2/2]

template<class T >
PODSpan< T > EBGeometry::PODVector< T >::bind ( void *  a_base) const
inlinenoexcept

Bind a mutable raw-pointer view for a hot loop.

The span must not outlive the next reserve on the pool; see PODSpan.

Parameters
[in]a_baseCurrent base address of the pool holding this array.
Returns
A PODSpan over the array.

◆ data() [1/2]

template<class T >
const T * EBGeometry::PODVector< T >::data ( const void *  a_base) const
inlinenoexcept

Const pointer to element 0 against a_base.

Parameters
[in]a_baseBase address of the pool holding this array.
Returns
Const pointer to element 0.

◆ data() [2/2]

template<class T >
T * EBGeometry::PODVector< T >::data ( void *  a_base) const
inlinenoexcept

Mutable pointer to element 0 against a_base.

Parameters
[in]a_baseBase address of the pool holding this array.
Returns
Pointer to element 0.

◆ empty()

template<class T >
bool EBGeometry::PODVector< T >::empty ( ) const
inlinenoexcept

Whether the array is empty.

Returns
True if m_size == 0.

◆ endByte()

template<class T >
uint64_t EBGeometry::PODVector< T >::endByte ( ) const
inlinenoexcept

One past the last byte this array occupies, measured from the pool base.

Deliberately computed from m_capacity rather than m_size: it bounds the reserved region, which is what a mirrored block must be large enough to contain. Used to check that an array actually fits inside a pool it is being rebased onto (see EBGeometry::DCEL::MeshT::rebasedView), which catches the realistic mistake of mirroring a pool before the last Pool::reserve.

Returns
m_offset + m_capacity * sizeof(T).

◆ push_back()

template<class T >
void EBGeometry::PODVector< T >::push_back ( void *  a_base,
const T &  a_value 
)
inline

Append one element into the pre-reserved capacity.

No reallocation ever: appending past capacity is an invariant violation. A host build-phase operation.

Parameters
[in]a_baseBase address of the pool holding this array.
[in]a_valueValue to append.

◆ reserveFrom()

template<class T >
void EBGeometry::PODVector< T >::reserveFrom ( Pool &  a_pool,
uint32_t  a_capacity 
)
inline

Reserve a_capacity slots from a_pool, aligned to alignof(T).

Sets m_offset and m_capacity and resets m_size to zero. A host build-phase operation.

Parameters
[in,out]a_poolPool to reserve from (must not be frozen).
[in]a_capacityNumber of element slots to reserve.

◆ size()

template<class T >
uint32_t EBGeometry::PODVector< T >::size ( ) const
inlinenoexcept

Number of constructed elements.

Returns
m_size.

The documentation for this struct was generated from the following file: