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

Base class for multi-sized 2D arrays. More...

#include <arcane/utils/MultiArray2.h>

Public Types

using ConstReferenceType = typename UniqueArray<DataType>::ConstReferenceType
using ThatClass = MultiArray2<DataType>

Public Member Functions

 MultiArray2 (ConstArrayView< Int32 > sizes)
 MultiArray2 (const ThatClass &rhs)=delete
ThatClass & operator= (const ThatClass &rhs)=delete
ArrayView< DataType > operator[] (Integer i)
ConstArrayView< DataType > operator[] (Integer i) const
Int32 totalNbElement () const
 Total number of elements.
void clear ()
 Clears the array elements.
void fill (const DataType &v)
 Fills the array elements with the value v.
DataType & at (Integer i, Integer j)
ConstReferenceType at (Integer i, Integer j) const
void setAt (Integer i, Integer j, ConstReferenceType v)
Int32 dim1Size () const
 Number of elements following the first dimension.
ConstArrayView< Int32dim2Sizes () const
 Array of the number of elements following the second dimension.
 operator MultiArray2View< DataType > ()
 Conversion operator to a mutable view.
 operator ConstMultiArray2View< DataType > () const
 Conversion operator to a constant view.
MultiArray2View< DataType > view ()
 Mutable view of the array.
ConstMultiArray2View< DataType > constView () const
 Constant view of the array.
JaggedSmallSpan< DataType > span ()
 Mutable view of the array.
JaggedSmallSpan< const DataType > span () const
 Constant view of the array.
JaggedSmallSpan< const DataType > constSpan () const
 Constant view of the array.
ArrayView< DataType > viewAsArray ()
 View of the array as a 1D array.
ConstArrayView< DataType > viewAsArray () const
 View of the array as a 1D array.
void resize (ConstArrayView< Int32 > new_sizes)
 Resizes the array with new sizes new_sizes.

Protected Member Functions

 MultiArray2 (const MultiArray2< DataType > &rhs, bool do_clone)
 Copy constructor. Temporary method to be removed once the copy constructor and copy operator are deleted.
 MultiArray2 (ConstMultiArray2View< DataType > aview)
 MultiArray2 (const MemoryAllocationOptions &allocation_options)
 MultiArray2 (const MemoryAllocationOptions &allocation_options, ConstArrayView< Int32 > sizes)
ConstArrayView< DataType > _value (Integer i) const
void _resize (ConstArrayView< Int32 > ar)
void _copy (const MultiArray2< DataType > &rhs, bool do_clone)
void _copy (ConstMultiArray2View< DataType > aview)

Detailed Description

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

Base class for multi-sized 2D arrays.

This class manages 2D arrays where the number of elements in the second dimension is variable. For example:

UniqueArray<Int32> sizes(3); // Array with 3 elements
sizes[0] = 1; sizes[1] = 2; sizes[2] = 4;
// Constructs the array with sizes as dimensions
MultiArray2<Int32> v(sizes);
info() << " size=" << v.dim1Size(); // displays 3
info() << " size[0]=" << v[0].size(); // displays 1
info() << " size[1]=" << v[1].size(); // displays 2
info() << " size[2]=" << v[2].size(); // displays 4
1D data vector with value semantics (STL style).
Note
Indices are stored using the Int32 type. The total number of elements in the array is therefore limited to 2^31

It is possible to resize (via the resize() method) the array while keeping its values, but for performance reasons, these resizes apply to the entire array (it is not possible to resize only a single element, for example v[5].resize(3)).

Like Array and Array2, instances of this class are not copyable or assignable. To get this functionality, you must use the SharedMultiArray2 class for reference semantics or UniqueMultiArray2 for value semantics.

Definition at line 59 of file MultiArray2.h.

Member Typedef Documentation

◆ ConstReferenceType

template<typename DataType>
using Arcane::MultiArray2< DataType >::ConstReferenceType = typename UniqueArray<DataType>::ConstReferenceType

Definition at line 63 of file MultiArray2.h.

◆ ThatClass

template<typename DataType>
using Arcane::MultiArray2< DataType >::ThatClass = MultiArray2<DataType>

Definition at line 64 of file MultiArray2.h.

Constructor & Destructor Documentation

◆ MultiArray2() [1/5]

template<typename DataType>
Arcane::MultiArray2< DataType >::MultiArray2 ( ConstArrayView< Int32 > sizes)
inlineexplicit

Definition at line 70 of file MultiArray2.h.

◆ MultiArray2() [2/5]

template<typename DataType>
Arcane::MultiArray2< DataType >::MultiArray2 ( const MultiArray2< DataType > & rhs,
bool do_clone )
inlineprotected

Copy constructor. Temporary method to be removed once the copy constructor and copy operator are deleted.

Definition at line 87 of file MultiArray2.h.

◆ MultiArray2() [3/5]

template<typename DataType>
Arcane::MultiArray2< DataType >::MultiArray2 ( ConstMultiArray2View< DataType > aview)
inlineexplicitprotected

Definition at line 93 of file MultiArray2.h.

◆ MultiArray2() [4/5]

template<typename DataType>
Arcane::MultiArray2< DataType >::MultiArray2 ( const MemoryAllocationOptions & allocation_options)
inlineexplicitprotected

Definition at line 99 of file MultiArray2.h.

◆ MultiArray2() [5/5]

template<typename DataType>
Arcane::MultiArray2< DataType >::MultiArray2 ( const MemoryAllocationOptions & allocation_options,
ConstArrayView< Int32 > sizes )
inlineprotected

Definition at line 105 of file MultiArray2.h.

Member Function Documentation

◆ _copy() [1/2]

template<typename DataType>
void Arcane::MultiArray2< DataType >::_copy ( const MultiArray2< DataType > & rhs,
bool do_clone )
inlineprotected

Definition at line 287 of file MultiArray2.h.

◆ _copy() [2/2]

template<typename DataType>
void Arcane::MultiArray2< DataType >::_copy ( ConstMultiArray2View< DataType > aview)
inlineprotected

Definition at line 293 of file MultiArray2.h.

◆ _resize()

template<typename DataType>
void Arcane::MultiArray2< DataType >::_resize ( ConstArrayView< Int32 > ar)
inlineprotected

Definition at line 233 of file MultiArray2.h.

◆ _value()

template<typename DataType>
ConstArrayView< DataType > Arcane::MultiArray2< DataType >::_value ( Integer i) const
inlineprotected

Definition at line 226 of file MultiArray2.h.

◆ at() [1/2]

template<typename DataType>
DataType & Arcane::MultiArray2< DataType >::at ( Integer i,
Integer j )
inline

Definition at line 139 of file MultiArray2.h.

◆ at() [2/2]

template<typename DataType>
ConstReferenceType Arcane::MultiArray2< DataType >::at ( Integer i,
Integer j ) const
inline

Definition at line 143 of file MultiArray2.h.

◆ clear()

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

Clears the array elements.

Definition at line 128 of file MultiArray2.h.

Referenced by Arcane::MultiArray2< Pointer >::resize().

◆ constSpan()

template<typename DataType>
JaggedSmallSpan< const DataType > Arcane::MultiArray2< DataType >::constSpan ( ) const
inline

Constant view of the array.

Definition at line 197 of file MultiArray2.h.

◆ constView()

template<typename DataType>
ConstMultiArray2View< DataType > Arcane::MultiArray2< DataType >::constView ( ) const
inline

◆ dim1Size()

template<typename DataType>
Int32 Arcane::MultiArray2< DataType >::dim1Size ( ) const
inline

Number of elements following the first dimension.

Definition at line 155 of file MultiArray2.h.

◆ dim2Sizes()

template<typename DataType>
ConstArrayView< Int32 > Arcane::MultiArray2< DataType >::dim2Sizes ( ) const
inline

Array of the number of elements following the second dimension.

Definition at line 158 of file MultiArray2.h.

◆ fill()

template<typename DataType>
void Arcane::MultiArray2< DataType >::fill ( const DataType & v)
inline

Fills the array elements with the value v.

Definition at line 135 of file MultiArray2.h.

◆ operator ConstMultiArray2View< DataType >()

template<typename DataType>
Arcane::MultiArray2< DataType >::operator ConstMultiArray2View< DataType > ( ) const
inline

Conversion operator to a constant view.

Definition at line 167 of file MultiArray2.h.

◆ operator MultiArray2View< DataType >()

template<typename DataType>
Arcane::MultiArray2< DataType >::operator MultiArray2View< DataType > ( )
inline

Conversion operator to a mutable view.

Definition at line 161 of file MultiArray2.h.

◆ operator[]() [1/2]

template<typename DataType>
ArrayView< DataType > Arcane::MultiArray2< DataType >::operator[] ( Integer i)
inline

Definition at line 113 of file MultiArray2.h.

◆ operator[]() [2/2]

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

Definition at line 117 of file MultiArray2.h.

◆ resize()

template<typename DataType>
void Arcane::MultiArray2< DataType >::resize ( ConstArrayView< Int32 > new_sizes)
inline

Resizes the array with new sizes new_sizes.

Definition at line 215 of file MultiArray2.h.

◆ setAt()

template<typename DataType>
void Arcane::MultiArray2< DataType >::setAt ( Integer i,
Integer j,
ConstReferenceType v )
inline

Definition at line 147 of file MultiArray2.h.

◆ span() [1/2]

template<typename DataType>
JaggedSmallSpan< DataType > Arcane::MultiArray2< DataType >::span ( )
inline

Mutable view of the array.

Definition at line 185 of file MultiArray2.h.

◆ span() [2/2]

template<typename DataType>
JaggedSmallSpan< const DataType > Arcane::MultiArray2< DataType >::span ( ) const
inline

Constant view of the array.

Definition at line 191 of file MultiArray2.h.

◆ totalNbElement()

template<typename DataType>
Int32 Arcane::MultiArray2< DataType >::totalNbElement ( ) const
inline

Total number of elements.

Definition at line 125 of file MultiArray2.h.

◆ view()

template<typename DataType>
MultiArray2View< DataType > Arcane::MultiArray2< DataType >::view ( )
inline

Mutable view of the array.

Definition at line 173 of file MultiArray2.h.

Referenced by Arcane::MultiArray2< bool >::operator MultiArray2View< bool >().

◆ viewAsArray() [1/2]

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

View of the array as a 1D array.

Definition at line 203 of file MultiArray2.h.

◆ viewAsArray() [2/2]

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

View of the array as a 1D array.

Definition at line 209 of file MultiArray2.h.


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