GEOSX
Public Types | Protected Member Functions | Protected Attributes | List of all members
LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE > Class Template Reference

This class provides a view into a SortedArray. More...

#include <SortedArrayView.hpp>

Inheritance diagram for LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >:
Inheritance graph
[legend]

Public Types

using ValueType = T
 The type of the values contained in the SortedArrayView.
 
using IndexType = INDEX_TYPE
 The integer type used for indexing.
 
using value_type = T
 The type of the values contained in the SortedArrayView, here for stl compatability.
 
using size_type = INDEX_TYPE
 The integer type used for indexing, here for stl compatability.
 

Public Member Functions

Constructors, destructor and assignment operators.
 SortedArrayView (SortedArrayView const &src)=default
 Default copy constructor. Performs a shallow copy and calls the chai::ManagedArray copy constructor. More...
 
constexpr SortedArrayView (SortedArrayView &&src)
 Default move constructor, performs a shallow copy. More...
 
constexpr SortedArrayView (INDEX_TYPE const size, BUFFER_TYPE< T > const &buffer)
 Construct a new SortedArrayView from the given buffer. More...
 
SortedArrayViewoperator= (SortedArrayView const &src)=default
 Default copy assignment operator, this does a shallow copy. More...
 
constexpr SortedArrayViewoperator= (SortedArrayView &&src)
 Default move assignment operator, this does a shallow copy. More...
 
SortedArrayView and ArraySlice creation methods
constexpr SortedArrayView< T const, INDEX_TYPE, BUFFER_TYPE > toView () const
 
constexpr SortedArrayView< T const, INDEX_TYPE, BUFFER_TYPE > toViewConst () const
 
constexpr ArraySlice< T const, 1, 0, INDEX_TYPE > toSlice () const &
 
constexpr ArraySlice< T const, 1, 0, INDEX_TYPE > toSlice () const &&=delete
 Overload for rvalues that is deleted. More...
 
Attribute querying methods
constexpr bool empty () const
 
constexpr INDEX_TYPE size () const
 
bool contains (T const &value) const
 
bool count (T const &value) const
 
Methods that provide access to the data.
constexpr T const & operator[] (INDEX_TYPE const i) const
 
constexpr T const & operator() (INDEX_TYPE const i) const
 
constexpr T const * data () const
 
constexpr T const * begin () const
 
constexpr T const * end () const
 
Methods dealing with memory spaces
void move (MemorySpace const space, bool touch=true) const
 Moves the SortedArrayView to the given execution space. More...
 

Protected Member Functions

 SortedArrayView ()
 Default constructor. More...
 

Protected Attributes

BUFFER_TYPE< T > m_values
 Holds the array of values.
 
INDEX_TYPE m_size = 0
 The number of values.
 

Detailed Description

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
class LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >

This class provides a view into a SortedArray.

Template Parameters
Ttype of data that is contained by the array.
INDEX_TYPEthe integer to use for indexing.

When using a SortedArrayView directly the template parameter T should be const since the View has no way of modifying the values. This also prevents unnecessary memory movement.

Definition at line 58 of file SortedArrayView.hpp.

Constructor & Destructor Documentation

◆ SortedArrayView() [1/4]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::SortedArrayView ( SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE > const &  src)
default

Default copy constructor. Performs a shallow copy and calls the chai::ManagedArray copy constructor.

Parameters
srcthe SortedArray to copy.

◆ SortedArrayView() [2/4]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::SortedArrayView ( SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE > &&  src)
inline

Default move constructor, performs a shallow copy.

Parameters
srcThe SortedArray to be moved from.

Definition at line 91 of file SortedArrayView.hpp.

◆ SortedArrayView() [3/4]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::SortedArrayView ( INDEX_TYPE const  size,
BUFFER_TYPE< T > const &  buffer 
)
inline

Construct a new SortedArrayView from the given buffer.

Parameters
sizeThe number of entries.
bufferThe values buffer, of size size.

Definition at line 104 of file SortedArrayView.hpp.

◆ SortedArrayView() [4/4]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::SortedArrayView ( )
inlineprotected

Default constructor.

Note
Protected since every SortedArrayView should either be the base of a SortedArray or copied from another SortedArrayView.

Definition at line 290 of file SortedArrayView.hpp.

Member Function Documentation

◆ begin()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr T const* LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::begin ( ) const
inline
Returns
Return an iterator to the beginning of the array.

Definition at line 248 of file SortedArrayView.hpp.

◆ contains()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
bool LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::contains ( T const &  value) const
inline
Returns
Return true if the value is in the array.
Parameters
valuethe value to search for.

Definition at line 196 of file SortedArrayView.hpp.

◆ count()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
bool LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::count ( T const &  value) const
inline
Returns
Return true if the given value is in the array.
Parameters
valuethe value to search for.
Note
This is a alias for contains to conform to the std::set interface.

Definition at line 205 of file SortedArrayView.hpp.

◆ data()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr T const* LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::data ( ) const
inline
Returns
Return a pointer to the values.

Definition at line 241 of file SortedArrayView.hpp.

◆ empty()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr bool LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::empty ( ) const
inline
Returns
Return true if the array holds no values.

Definition at line 181 of file SortedArrayView.hpp.

◆ end()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr T const* LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::end ( ) const
inline
Returns
Return an iterator to the end of the array.

Definition at line 255 of file SortedArrayView.hpp.

◆ move()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
void LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::move ( MemorySpace const  space,
bool  touch = true 
) const
inline

Moves the SortedArrayView to the given execution space.

Parameters
spacethe space to move to.
touchIf the values will be modified in the new space.
Note
Since the SortedArrayView can't be modified on device when moving to the GPU touch is set to false.

Definition at line 273 of file SortedArrayView.hpp.

◆ operator()()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr T const& LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::operator() ( INDEX_TYPE const  i) const
inline
Returns
Return the value at position i .
Parameters
ithe index of the value to access.

Definition at line 231 of file SortedArrayView.hpp.

◆ operator=() [1/2]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
SortedArrayView& LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::operator= ( SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE > const &  src)
default

Default copy assignment operator, this does a shallow copy.

Parameters
srcThe SortedArray to copy.
Returns
*this.

◆ operator=() [2/2]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr SortedArrayView& LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::operator= ( SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE > &&  src)
inline

Default move assignment operator, this does a shallow copy.

Parameters
srcthe SortedArray to be moved from.
Returns
*this.

Definition at line 122 of file SortedArrayView.hpp.

◆ operator[]()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr T const& LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::operator[] ( INDEX_TYPE const  i) const
inline
Returns
Return the value at position i .
Parameters
ithe index of the value to access.

Definition at line 220 of file SortedArrayView.hpp.

◆ size()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr INDEX_TYPE LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::size ( ) const
inline
Returns
Return the number of values in the array.

Definition at line 188 of file SortedArrayView.hpp.

◆ toSlice() [1/2]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr ArraySlice< T const, 1, 0, INDEX_TYPE > LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::toSlice ( ) const &
inline
Returns
Return an ArraySlice representing this SortedArrayView.

Definition at line 157 of file SortedArrayView.hpp.

◆ toSlice() [2/2]

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr ArraySlice< T const, 1, 0, INDEX_TYPE > LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::toSlice ( ) const &&
inlinedelete

Overload for rvalues that is deleted.

Returns
A null ArraySlice.
Note
This cannot be called on a rvalue since the ArraySlice would contain pointers to the size of the current SortedArrayView that is about to be destroyed. This overload prevents that from happening.

◆ toView()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr SortedArrayView< T const, INDEX_TYPE, BUFFER_TYPE > LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::toView ( ) const
inline
Returns
An immutable SortedArrayView.

Definition at line 142 of file SortedArrayView.hpp.

◆ toViewConst()

template<typename T, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr SortedArrayView< T const, INDEX_TYPE, BUFFER_TYPE > LvArray::SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >::toViewConst ( ) const
inline
Returns
An immutable SortedArrayView.

Definition at line 150 of file SortedArrayView.hpp.


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