BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
belfem::Cell< T > Class Template Reference

A bounds-checked wrapper around std::vector. More...

#include <cl_Cell.hpp>

Public Member Functions

 Cell ()=default
 Cell (const std::size_t aReserve)
 Creates an empty Cell with capacity for aReserve elements.
 Cell (const std::size_t aSize, const T aInitializationValue)
 Cell (const std::initializer_list< T > &aInitList)
 Cell (const Cell< T > &other)
 Cell (Cell< T > &&other) noexcept
Cell< T > & operator= (const Cell< T > &other)
Cell< T > & operator= (Cell< T > &&other) noexcept
 ~Cell ()=default
T * data ()
 Returns a borrowed pointer into contiguous storage, possibly nullptr when the Cell is empty ( test size(), never data() ).
const T * data () const
std::vector< T > & vector_data ()
 The underlying vector.
const std::vector< T > & vector_data () const
auto operator() (size_t aIndex) -> decltype(mCell[aIndex])
auto operator() (size_t aIndex) const -> decltype(mCell[aIndex])
size_t size () const
void set_size (const size_t aSize)
 New elements are value-initialized ( zero for arithmetic T, nullptr for pointers ).
void set_size (const size_t aSize, const T &aValue)
auto begin () -> decltype(mCell.begin())
auto end () -> decltype(mCell.end())
auto begin () const -> decltype(mCell.begin())
auto end () const -> decltype(mCell.end())
void clear ()
 Empties the Cell.
void reserve (const size_t aSize)
void push (const T &aValue)
void push (T &&aValue)
template<typename... Args>
void emplace (Args &&... args)
T pop ()
void shrink_to_fit ()
T & first ()
const T & first () const
T & last ()
const T & last () const
void swap (Cell< T > &other) noexcept
 Swap contents with another Cell.
bool empty () const
size_t capacity () const
auto insert (typename std::vector< T >::const_iterator pos, const T &valuevalue) -> decltype(mCell.insert(pos, valuevalue))
auto insert (typename std::vector< T >::const_iterator pos, T &&valuevalue) -> decltype(mCell.insert(pos, std::move(valuevalue)))
auto erase (typename std::vector< T >::const_iterator pos) -> decltype(mCell.erase(pos))
auto erase (typename std::vector< T >::const_iterator first, typename std::vector< T >::const_iterator last) -> decltype(mCell.erase(first, last))
 Erase range of elements.
void print (const std::string aLabel="") const
void print (const std::string aLabel) const

Detailed Description

template<typename T>
class belfem::Cell< T >

A bounds-checked wrapper around std::vector.

A Cell< T > owns its elements. A Cell< T* > stores pointers but does not own the pointees. Destruction, clear() and set_size() do not delete them. Copying a Cell< T* > copies the pointers. sort(), unique(), reverse() and append() are free functions.

See also
BELFEM Container Classes - Usage Guide

Constructor & Destructor Documentation

◆ Cell() [1/6]

template<typename T>
belfem::Cell< T >::Cell ( )
default

◆ Cell() [2/6]

template<typename T>
belfem::Cell< T >::Cell ( const std::size_t aReserve)
inline

Creates an empty Cell with capacity for aReserve elements.

size() is 0 and operator() is out of bounds until push() or set_size(). The two-argument constructor creates elements.

◆ Cell() [3/6]

template<typename T>
belfem::Cell< T >::Cell ( const std::size_t aSize,
const T aInitializationValue )
inline

◆ Cell() [4/6]

template<typename T>
belfem::Cell< T >::Cell ( const std::initializer_list< T > & aInitList)
inline

◆ Cell() [5/6]

template<typename T>
belfem::Cell< T >::Cell ( const Cell< T > & other)
inline

◆ Cell() [6/6]

template<typename T>
belfem::Cell< T >::Cell ( Cell< T > && other)
inlinenoexcept

◆ ~Cell()

template<typename T>
belfem::Cell< T >::~Cell ( )
default

Member Function Documentation

◆ begin() [1/2]

template<typename T>
auto belfem::Cell< T >::begin ( ) -> decltype(mCell.begin())
inline

◆ begin() [2/2]

template<typename T>
auto belfem::Cell< T >::begin ( ) const -> decltype(mCell.begin())
inline

◆ capacity()

template<typename T>
size_t belfem::Cell< T >::capacity ( ) const
inline

◆ clear()

template<typename T>
void belfem::Cell< T >::clear ( )
inline

Empties the Cell.

It retains its capacity; shrink_to_fit() asks the vector to release it. Pointees of a Cell< T* > are not deleted.

◆ data() [1/2]

template<typename T>
T * belfem::Cell< T >::data ( )
inline

Returns a borrowed pointer into contiguous storage, possibly nullptr when the Cell is empty ( test size(), never data() ).

Any call that may reallocate invalidates it. MPI accepts it at count 0.

◆ data() [2/2]

template<typename T>
const T * belfem::Cell< T >::data ( ) const
inline

◆ emplace()

template<typename T>
template<typename... Args>
void belfem::Cell< T >::emplace ( Args &&... args)
inline

◆ empty()

template<typename T>
bool belfem::Cell< T >::empty ( ) const
inline

◆ end() [1/2]

template<typename T>
auto belfem::Cell< T >::end ( ) -> decltype(mCell.end())
inline

◆ end() [2/2]

template<typename T>
auto belfem::Cell< T >::end ( ) const -> decltype(mCell.end())
inline

◆ erase() [1/2]

template<typename T>
auto belfem::Cell< T >::erase ( typename std::vector< T >::const_iterator first,
typename std::vector< T >::const_iterator last ) -> decltype(mCell.erase(first, last))
inline

Erase range of elements.

◆ erase() [2/2]

template<typename T>
auto belfem::Cell< T >::erase ( typename std::vector< T >::const_iterator pos) -> decltype(mCell.erase(pos))
inline

◆ first() [1/2]

template<typename T>
T & belfem::Cell< T >::first ( )
inline

◆ first() [2/2]

template<typename T>
const T & belfem::Cell< T >::first ( ) const
inline

◆ insert() [1/2]

template<typename T>
auto belfem::Cell< T >::insert ( typename std::vector< T >::const_iterator pos,
const T & value ) -> decltype(mCell.insert(pos, value))
inline

◆ insert() [2/2]

template<typename T>
auto belfem::Cell< T >::insert ( typename std::vector< T >::const_iterator pos,
T && value ) -> decltype(mCell.insert(pos, std::move(value)))
inline

◆ last() [1/2]

template<typename T>
T & belfem::Cell< T >::last ( )
inline

◆ last() [2/2]

template<typename T>
const T & belfem::Cell< T >::last ( ) const
inline

◆ operator()() [1/2]

template<typename T>
auto belfem::Cell< T >::operator() ( size_t aIndex) -> decltype(mCell[aIndex])
inline

◆ operator()() [2/2]

template<typename T>
auto belfem::Cell< T >::operator() ( size_t aIndex) const -> decltype(mCell[aIndex])
inline

◆ operator=() [1/2]

template<typename T>
Cell< T > & belfem::Cell< T >::operator= ( Cell< T > && other)
inlinenoexcept

◆ operator=() [2/2]

template<typename T>
Cell< T > & belfem::Cell< T >::operator= ( const Cell< T > & other)
inline

◆ pop()

template<typename T>
T belfem::Cell< T >::pop ( )
inline

◆ print() [1/2]

void belfem::Cell< real >::print ( const std::string aLabel) const
inline

◆ print() [2/2]

template<typename T>
void belfem::Cell< T >::print ( const std::string aLabel = "") const

◆ push() [1/2]

template<typename T>
void belfem::Cell< T >::push ( const T & aValue)
inline

◆ push() [2/2]

template<typename T>
void belfem::Cell< T >::push ( T && aValue)
inline

◆ reserve()

template<typename T>
void belfem::Cell< T >::reserve ( const size_t aSize)
inline

◆ set_size() [1/2]

template<typename T>
void belfem::Cell< T >::set_size ( const size_t aSize)
inline

New elements are value-initialized ( zero for arithmetic T, nullptr for pointers ).

The two-argument overload sets a value.

◆ set_size() [2/2]

template<typename T>
void belfem::Cell< T >::set_size ( const size_t aSize,
const T & aValue )
inline

◆ shrink_to_fit()

template<typename T>
void belfem::Cell< T >::shrink_to_fit ( )
inline

◆ size()

template<typename T>
size_t belfem::Cell< T >::size ( ) const
inline

◆ swap()

template<typename T>
void belfem::Cell< T >::swap ( Cell< T > & other)
inlinenoexcept

Swap contents with another Cell.

◆ vector_data() [1/2]

template<typename T>
std::vector< T > & belfem::Cell< T >::vector_data ( )
inline

The underlying vector.

Resizing it here bypasses the bounds checks of operator().

◆ vector_data() [2/2]

template<typename T>
const std::vector< T > & belfem::Cell< T >::vector_data ( ) const
inline

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