Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::Array2< DataType > Class Template Reference

Class representing a classic 2D array. More...

#include <arccore/collections/Array2.h>

Public Member Functions

ArrayView< DataType > operator[] (Int64 i)
ConstArrayView< DataType > operator[] (Int64 i) const
ArrayView< DataType > operator() (Int64 i)
ConstArrayView< DataType > operator() (Int64 i) const
DataType & operator() (Int64 i, Int64 j)
ConstReferenceType operator() (Int64 i, Int64 j) const
DataType item (Int64 i, Int64 j)
void setItem (Int64 i, Int64 j, ConstReferenceType v)
ConstArrayView< DataType > at (Int64 i) const
 Element at index i. Always checks for bounds.
ArrayView< DataType > at (Int64 i)
 Element at index i. Always checks for bounds.
DataType at (Int64 i, Int64 j)
void fill (ConstReferenceType v)
void clear ()
Array2< DataType > clone ()
void copy (Span2< const DataType > rhs)
 Resizes the instance based on the dimensions of rhs and copies the values of rhs into it.
Integer capacity () const
 Capacity (number of allocated elements) of the array.
Int64 largeCapacity () const
 Capacity (number of allocated elements) of the array.
void reserve (Int64 new_capacity)
 Reserves memory for new_capacity elements.
void shrink ()
void shrink (Int64 new_capacity)
 Reallocates memory to have a capacity close to new_capacity.
void shrink_to_fit ()
ArrayView< DataType > viewAsArray ()
 View of the array as a 1D array.
ConstArrayView< DataType > viewAsArray () const
 View of the array as a 1D array.
Span< DataType > to1DSpan ()
 View of the array as a 1D array.
Span< const DataType > to1DSpan () const
 View of the array as a 1D array.
 operator Array2View< DataType > ()
 operator ConstArray2View< DataType > () const
 operator Span2< const DataType > () const
 operator Span2< DataType > ()
Array2View< DataType > view ()
ConstArray2View< DataType > constView () const
Span2< DataType > span ()
Span2< const DataType > constSpan () const
Integer dim2Size () const
Integer dim1Size () const
Int64 largeDim2Size () const
Int64 largeDim1Size () const
void add (const DataType &value)
void resize (Int64 new_size)
 Resizes only the first dimension, leaving the second dimension unchanged.
void resizeNoInit (Int64 new_size)
 Resizes only the first dimension, leaving the second dimension unchanged.
void resize (Int64 new_size1, Int64 new_size2)
 Reallocates both dimensions.
void resizeNoInit (Int64 new_size1, Int64 new_size2)
 Reallocates both dimensions.
Integer totalNbElement () const
 Total number of elements (dim1Size()*dim2Size()).
Int64 largeTotalNbElement () const
 Total number of elements (largeDim1Size()*largeDim2Size()).
MemoryAllocationOptions allocationOptions () const
String debugName () const
 Debug name (null if no name specified).
void setDebugName (const String &name)
 Sets the array name for debug information.

Protected Types

enum  CloneBehaviour { CB_Clone , CB_Shared }
enum  InitBehaviour { IB_InitWithDefault , IB_NoInit }

Protected Member Functions

 Array2 (Int64 size1, Int64 size2)
 Creates an array of size1 * size2 elements.
 Array2 (ConstArray2View< DataType > rhs)
 Array2 (const Span2< const DataType > &rhs)
 Array2 (IMemoryAllocator *allocator)
 Creates an empty array with a specific allocator allocator.
 Array2 (IMemoryAllocator *allocator, Int64 size1, Int64 size2)
 Creates an array of size1 * size2 elements with a specific allocator allocator.
 Array2 (Array2< DataType > &&rhs)
 Move constructor. Only valid for UniqueArray2.
void _resize (Int64 new_size, InitBehaviour rb)
 Resizes only the first dimension, leaving the second dimension unchanged.
void _resize (Int64 new_size1, Int64 new_size2, InitBehaviour rb)
 Reallocates both dimensions.
void _resizeFromEmpty (Int64 new_size1, Int64 new_size2, InitBehaviour rb)
void _resizeSameDim1ReduceDim2 (Int64 new_size2, InitBehaviour rb)
void _resizeSameDim1IncreaseDim2 (Int64 new_size2, InitBehaviour rb)
void _resize2 (Int64 d1, Int64 d2, InitBehaviour rb)
void _move (Array2< DataType > &rhs)
void _swap (Array2< DataType > &rhs)
void _assignFromArray2 (const Array2< DataType > &rhs)
void _resizeAndCopyView (Span2< const DataType > rhs)
void _copyMetaData (const Array2< DataType > &rhs)
void _destroy ()
void _initFromAllocator (MemoryAllocationOptions o, Int64 acapacity, void *pre_allocated_buffer=nullptr)
 Constructs an empty vector with a specific allocator a.
void _internalDeallocate (RunQueue *queue=nullptr)
void _setMP (TrueImpl *new_mp)
void _setMP2 (TrueImpl *new_mp, ArrayMetaData *new_md)

Protected Attributes

DataType * m_ptr

Detailed Description

template<typename DataType>
class Arcane::Array2< DataType >

Class representing a classic 2D array.

Instances of this class are neither copyable nor assignable. To create a copyable array, you must use SharedArray2 (for reference semantics) or UniqueArray2 (for value semantics like STL).

Definition at line 42 of file arccore/src/collections/arccore/collections/Array2.h.

Member Enumeration Documentation

◆ CloneBehaviour

template<typename DataType>
enum Arcane::Array2::CloneBehaviour
protected

◆ InitBehaviour

template<typename DataType>
enum Arcane::Array2::InitBehaviour
protected

Constructor & Destructor Documentation

◆ Array2() [1/7]

template<typename DataType>
Arcane::Array2< DataType >::Array2 ( )
inlineprotected

◆ Array2() [2/7]

template<typename DataType>
Arcane::Array2< DataType >::Array2 ( Int64 size1,
Int64 size2 )
inlineprotected

Creates an array of size1 * size2 elements.

Definition at line 90 of file arccore/src/collections/arccore/collections/Array2.h.

◆ Array2() [3/7]

template<typename DataType>
Arcane::Array2< DataType >::Array2 ( ConstArray2View< DataType > rhs)
inlineprotected

◆ Array2() [4/7]

template<typename DataType>
Arcane::Array2< DataType >::Array2 ( const Span2< const DataType > & rhs)
inlineprotected

◆ Array2() [5/7]

template<typename DataType>
Arcane::Array2< DataType >::Array2 ( IMemoryAllocator * allocator)
inlineexplicitprotected

Creates an empty array with a specific allocator allocator.

Definition at line 109 of file arccore/src/collections/arccore/collections/Array2.h.

◆ Array2() [6/7]

template<typename DataType>
Arcane::Array2< DataType >::Array2 ( IMemoryAllocator * allocator,
Int64 size1,
Int64 size2 )
inlineprotected

Creates an array of size1 * size2 elements with a specific allocator allocator.

Definition at line 118 of file arccore/src/collections/arccore/collections/Array2.h.

◆ Array2() [7/7]

template<typename DataType>
Arcane::Array2< DataType >::Array2 ( Array2< DataType > && rhs)
inlineprotected

Move constructor. Only valid for UniqueArray2.

Definition at line 136 of file arccore/src/collections/arccore/collections/Array2.h.

Member Function Documentation

◆ _assignFromArray2()

template<typename DataType>
void Arcane::Array2< DataType >::_assignFromArray2 ( const Array2< DataType > & rhs)
inlineprotected

◆ _copyMetaData()

template<typename DataType>
void Arcane::Array2< DataType >::_copyMetaData ( const Array2< DataType > & rhs)
inlineprotected

◆ _destroy()

template<typename DataType>
void Arcane::AbstractArray< DataType >::_destroy ( )
inlineprotected

Definition at line 626 of file AbstractArray.h.

◆ _initFromAllocator()

template<typename DataType>
void Arcane::AbstractArray< DataType >::_initFromAllocator ( MemoryAllocationOptions o,
Int64 acapacity,
void * pre_allocated_buffer = nullptr )
inlineprotected

Constructs an empty vector with a specific allocator a.

If acapacity is not null, memory is allocated to hold acapacity elements (but the array remains empty).

This method must only be called in a derived class constructor and only by classes using UniqueArray semantics.

Definition at line 262 of file AbstractArray.h.

Referenced by Arcane::Array2< T >::Array2(), and Arcane::Array2< T >::Array2().

◆ _internalDeallocate()

template<typename DataType>
void Arcane::AbstractArray< DataType >::_internalDeallocate ( RunQueue * queue = nullptr)
inlineprotected

Definition at line 494 of file AbstractArray.h.

◆ _move()

template<typename DataType>
void Arcane::Array2< DataType >::_move ( Array2< DataType > & rhs)
inlineprotected

◆ _resize() [1/2]

template<typename DataType>
void Arcane::Array2< DataType >::_resize ( Int64 new_size,
InitBehaviour rb )
inlineprotected

◆ _resize() [2/2]

template<typename DataType>
void Arcane::Array2< DataType >::_resize ( Int64 new_size1,
Int64 new_size2,
InitBehaviour rb )
inlineprotected

Reallocates both dimensions.

Definition at line 386 of file arccore/src/collections/arccore/collections/Array2.h.

◆ _resize2()

template<typename DataType>
void Arcane::Array2< DataType >::_resize2 ( Int64 d1,
Int64 d2,
InitBehaviour rb )
inlineprotected

◆ _resizeAndCopyView()

template<typename DataType>
void Arcane::Array2< DataType >::_resizeAndCopyView ( Span2< const DataType > rhs)
inlineprotected

◆ _resizeFromEmpty()

template<typename DataType>
void Arcane::Array2< DataType >::_resizeFromEmpty ( Int64 new_size1,
Int64 new_size2,
InitBehaviour rb )
inlineprotected

◆ _resizeSameDim1IncreaseDim2()

template<typename DataType>
void Arcane::Array2< DataType >::_resizeSameDim1IncreaseDim2 ( Int64 new_size2,
InitBehaviour rb )
inlineprotected

◆ _resizeSameDim1ReduceDim2()

template<typename DataType>
void Arcane::Array2< DataType >::_resizeSameDim1ReduceDim2 ( Int64 new_size2,
InitBehaviour rb )
inlineprotected

◆ _setMP()

template<typename DataType>
void Arcane::AbstractArray< DataType >::_setMP ( TrueImpl * new_mp)
inlineprotected

Definition at line 877 of file AbstractArray.h.

◆ _setMP2()

template<typename DataType>
void Arcane::AbstractArray< DataType >::_setMP2 ( TrueImpl * new_mp,
ArrayMetaData * new_md )
inlineprotected

Definition at line 882 of file AbstractArray.h.

◆ _swap()

template<typename DataType>
void Arcane::Array2< DataType >::_swap ( Array2< DataType > & rhs)
inlineprotected

◆ add()

template<typename DataType>
void Arcane::Array2< DataType >::add ( const DataType & value)
inline

◆ allocationOptions()

template<typename DataType>
MemoryAllocationOptions Arcane::AbstractArrayBase::allocationOptions ( ) const
inline

Definition at line 63 of file AbstractArray.h.

◆ at() [1/3]

template<typename DataType>
ArrayView< DataType > Arcane::Array2< DataType >::at ( Int64 i)
inline

Element at index i. Always checks for bounds.

Definition at line 205 of file arccore/src/collections/arccore/collections/Array2.h.

◆ at() [2/3]

template<typename DataType>
ConstArrayView< DataType > Arcane::Array2< DataType >::at ( Int64 i) const
inline

Element at index i. Always checks for bounds.

Definition at line 199 of file arccore/src/collections/arccore/collections/Array2.h.

Referenced by Arcane::Array2VariableT< T >::compact().

◆ at() [3/3]

template<typename DataType>
DataType Arcane::Array2< DataType >::at ( Int64 i,
Int64 j )
inline

◆ capacity()

template<typename DataType>
Integer Arcane::Array2< DataType >::capacity ( ) const
inline

Capacity (number of allocated elements) of the array.

Definition at line 238 of file arccore/src/collections/arccore/collections/Array2.h.

◆ clear()

template<typename DataType>
void Arcane::Array2< DataType >::clear ( )
inline

◆ clone()

template<typename DataType>
Array2< DataType > Arcane::Array2< DataType >::clone ( )
inline

◆ constSpan()

template<typename DataType>
Span2< const DataType > Arcane::Array2< DataType >::constSpan ( ) const
inline

◆ constView()

template<typename DataType>
ConstArray2View< DataType > Arcane::Array2< DataType >::constView ( ) const
inline

◆ copy()

template<typename DataType>
void Arcane::Array2< DataType >::copy ( Span2< const DataType > rhs)
inline

Resizes the instance based on the dimensions of rhs and copies the values of rhs into it.

Definition at line 233 of file arccore/src/collections/arccore/collections/Array2.h.

Referenced by Arcane::Array2VariableT< T >::_compareVariable().

◆ debugName()

template<typename DataType>
String Arcane::AbstractArrayBase::debugName ( ) const

Debug name (null if no name specified).

Definition at line 74 of file arccore/src/common/arccore/common/Array.cc.

◆ dim1Size()

template<typename DataType>
Integer Arcane::Array2< DataType >::dim1Size ( ) const
inline

◆ dim2Size()

template<typename DataType>
Integer Arcane::Array2< DataType >::dim2Size ( ) const
inline

◆ fill()

template<typename DataType>
void Arcane::Array2< DataType >::fill ( ConstReferenceType v)
inline

◆ item()

template<typename DataType>
DataType Arcane::Array2< DataType >::item ( Int64 i,
Int64 j )
inline

◆ largeCapacity()

template<typename DataType>
Int64 Arcane::Array2< DataType >::largeCapacity ( ) const
inline

Capacity (number of allocated elements) of the array.

Definition at line 241 of file arccore/src/collections/arccore/collections/Array2.h.

◆ largeDim1Size()

template<typename DataType>
Int64 Arcane::Array2< DataType >::largeDim1Size ( ) const
inline

◆ largeDim2Size()

template<typename DataType>
Int64 Arcane::Array2< DataType >::largeDim2Size ( ) const
inline

◆ largeTotalNbElement()

template<typename DataType>
Int64 Arcane::Array2< DataType >::largeTotalNbElement ( ) const
inline

Total number of elements (largeDim1Size()*largeDim2Size()).

Definition at line 370 of file arccore/src/collections/arccore/collections/Array2.h.

◆ operator Array2View< DataType >()

template<typename DataType>
Arcane::Array2< DataType >::operator Array2View< DataType > ( )
inline

◆ operator ConstArray2View< DataType >()

template<typename DataType>
Arcane::Array2< DataType >::operator ConstArray2View< DataType > ( ) const
inline

◆ operator Span2< const DataType >()

template<typename DataType>
Arcane::Array2< DataType >::operator Span2< const DataType > ( ) const
inline

◆ operator Span2< DataType >()

template<typename DataType>
Arcane::Array2< DataType >::operator Span2< DataType > ( )
inline

◆ operator()() [1/4]

template<typename DataType>
ArrayView< DataType > Arcane::Array2< DataType >::operator() ( Int64 i)
inline

◆ operator()() [2/4]

template<typename DataType>
ConstArrayView< DataType > Arcane::Array2< DataType >::operator() ( Int64 i) const
inline

◆ operator()() [3/4]

template<typename DataType>
DataType & Arcane::Array2< DataType >::operator() ( Int64 i,
Int64 j )
inline

◆ operator()() [4/4]

template<typename DataType>
ConstReferenceType Arcane::Array2< DataType >::operator() ( Int64 i,
Int64 j ) const
inline

◆ operator[]() [1/2]

template<typename DataType>
ArrayView< DataType > Arcane::Array2< DataType >::operator[] ( Int64 i)
inline

◆ operator[]() [2/2]

template<typename DataType>
ConstArrayView< DataType > Arcane::Array2< DataType >::operator[] ( Int64 i) const
inline

◆ reserve()

template<typename DataType>
void Arcane::Array2< DataType >::reserve ( Int64 new_capacity)
inline

Reserves memory for new_capacity elements.

Definition at line 244 of file arccore/src/collections/arccore/collections/Array2.h.

◆ resize() [1/2]

template<typename DataType>
void Arcane::Array2< DataType >::resize ( Int64 new_size)
inline

Resizes only the first dimension, leaving the second dimension unchanged.

Any new values are initialized with the default constructor.

Definition at line 330 of file arccore/src/collections/arccore/collections/Array2.h.

Referenced by Arcane::Array2< T >::Array2(), Arcane::Array2< T >::Array2(), and Arcane::Array2VariableT< T >::compact().

◆ resize() [2/2]

template<typename DataType>
void Arcane::Array2< DataType >::resize ( Int64 new_size1,
Int64 new_size2 )
inline

Reallocates both dimensions.

Any new values are initialized with the default constructor.

Definition at line 351 of file arccore/src/collections/arccore/collections/Array2.h.

◆ resizeNoInit() [1/2]

template<typename DataType>
void Arcane::Array2< DataType >::resizeNoInit ( Int64 new_size)
inline

Resizes only the first dimension, leaving the second dimension unchanged.

Any new values are NOT initialized.

Definition at line 341 of file arccore/src/collections/arccore/collections/Array2.h.

◆ resizeNoInit() [2/2]

template<typename DataType>
void Arcane::Array2< DataType >::resizeNoInit ( Int64 new_size1,
Int64 new_size2 )
inline

Reallocates both dimensions.

Any new values are NOT initialized.

Definition at line 361 of file arccore/src/collections/arccore/collections/Array2.h.

◆ setDebugName()

template<typename DataType>
void Arcane::AbstractArrayBase::setDebugName ( const String & name)

Sets the array name for debug information.

This name can be used, for example, for listing displays.

Definition at line 72 of file arccore/src/common/arccore/common/Array.cc.

◆ setItem()

template<typename DataType>
void Arcane::Array2< DataType >::setItem ( Int64 i,
Int64 j,
ConstReferenceType v )
inline

◆ shrink() [1/2]

template<typename DataType>
void Arcane::Array2< DataType >::shrink ( )
inline

◆ shrink() [2/2]

template<typename DataType>
void Arcane::Array2< DataType >::shrink ( Int64 new_capacity)
inline

Reallocates memory to have a capacity close to new_capacity.

Definition at line 250 of file arccore/src/collections/arccore/collections/Array2.h.

◆ shrink_to_fit()

template<typename DataType>
void Arcane::Array2< DataType >::shrink_to_fit ( )
inline

◆ span()

template<typename DataType>
Span2< DataType > Arcane::Array2< DataType >::span ( )
inline

◆ to1DSpan() [1/2]

template<typename DataType>
Span< DataType > Arcane::Array2< DataType >::to1DSpan ( )
inline

View of the array as a 1D array.

Definition at line 266 of file arccore/src/collections/arccore/collections/Array2.h.

◆ to1DSpan() [2/2]

template<typename DataType>
Span< const DataType > Arcane::Array2< DataType >::to1DSpan ( ) const
inline

View of the array as a 1D array.

Definition at line 271 of file arccore/src/collections/arccore/collections/Array2.h.

◆ totalNbElement()

template<typename DataType>
Integer Arcane::Array2< DataType >::totalNbElement ( ) const
inline

Total number of elements (dim1Size()*dim2Size()).

Definition at line 367 of file arccore/src/collections/arccore/collections/Array2.h.

Referenced by Arcane::Array2< T >::_resize().

◆ view()

template<typename DataType>
Array2View< DataType > Arcane::Array2< DataType >::view ( )
inline

◆ viewAsArray() [1/2]

template<typename DataType>
ArrayView< DataType > Arcane::Array2< DataType >::viewAsArray ( )
inline

View of the array as a 1D array.

Definition at line 256 of file arccore/src/collections/arccore/collections/Array2.h.

◆ viewAsArray() [2/2]

template<typename DataType>
ConstArrayView< DataType > Arcane::Array2< DataType >::viewAsArray ( ) const
inline

View of the array as a 1D array.

Definition at line 261 of file arccore/src/collections/arccore/collections/Array2.h.

Member Data Documentation

◆ m_ptr

template<typename DataType>
DataType* Arcane::AbstractArray< DataType >::m_ptr
protected

Definition at line 413 of file AbstractArray.h.


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