Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::SharedArray2< T > Class Template Reference

Shared 2D data vector with reference semantics. More...

#include </__w/arcaneframework.github.io/arcaneframework.github.io/framework/arccore/src/collections/arccore/collections/Array2.h>

Inheritance diagram for Arcane::SharedArray2< T >:
Collaboration diagram for Arcane::SharedArray2< T >:

Public Types

typedef SharedArray2< T > ThatClassType
typedef AbstractArray< T > BaseClassType
typedef BaseClassType::ConstReferenceType ConstReferenceType

Public Member Functions

 SharedArray2 ()=default
 Creates an empty array.
 SharedArray2 (Int64 size1, Int64 size2)
 Creates an array of size1 * size2 elements.
 SharedArray2 (const ConstArray2View< T > &view)
 Creates an array by copying the values from the view.
 SharedArray2 (const Span2< const T > &view)
 Creates an array by copying the values from the view.
 SharedArray2 (const SharedArray2< T > &rhs)
 Creates an array referencing rhs.
 SharedArray2 (const UniqueArray2< T > &rhs)
 Creates an array by copying the values of rhs.
void operator= (const SharedArray2< T > &rhs)
 Changes the reference of this instance to that of rhs.
void operator= (const UniqueArray2< T > &rhs)
 Copies the values of rhs into this instance.
void operator= (const ConstArray2View< T > &rhs)
 Copies the values of the view rhs into this instance.
void operator= (const Span2< const T > &rhs)
 Copies the values of the view rhs into this instance.
 ~SharedArray2 () override
 Destroys the instance.
SharedArray2< T > clone () const
 Clones the array.
Public Member Functions inherited from Arcane::Array2< T >
ArrayView< T > operator[] (Int64 i)
ConstArrayView< T > operator[] (Int64 i) const
ArrayView< T > operator() (Int64 i)
ConstArrayView< T > operator() (Int64 i) const
T & operator() (Int64 i, Int64 j)
ConstReferenceType operator() (Int64 i, Int64 j) const
item (Int64 i, Int64 j)
void setItem (Int64 i, Int64 j, ConstReferenceType v)
ConstArrayView< T > at (Int64 i) const
 Element at index i. Always checks for bounds.
ArrayView< T > at (Int64 i)
 Element at index i. Always checks for bounds.
at (Int64 i, Int64 j)
void fill (ConstReferenceType v)
void clear ()
Array2< T > clone ()
void copy (Span2< const T > 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< T > viewAsArray ()
 View of the array as a 1D array.
ConstArrayView< T > viewAsArray () const
 View of the array as a 1D array.
Span< T > to1DSpan ()
 View of the array as a 1D array.
Span< const T > to1DSpan () const
 View of the array as a 1D array.
 operator Array2View< T > ()
 operator ConstArray2View< T > () const
 operator Span2< const T > () const
 operator Span2< T > ()
Array2View< T > view ()
ConstArray2View< T > constView () const
Span2< T > span ()
Span2< const T > constSpan () const
Integer dim2Size () const
Integer dim1Size () const
Int64 largeDim2Size () const
Int64 largeDim1Size () const
void add (const T &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.
ArrayView< T > operator[] (Int64 i)
ConstArrayView< T > operator[] (Int64 i) const
ArrayView< T > operator() (Int64 i)
ConstArrayView< T > operator() (Int64 i) const
T & operator() (Int64 i, Int64 j)
ConstReferenceType operator() (Int64 i, Int64 j) const
item (Int64 i, Int64 j)
void setItem (Int64 i, Int64 j, ConstReferenceType v)
ConstArrayView< T > at (Int64 i) const
 Element at index i. Always checks for bounds.
ArrayView< T > at (Int64 i)
 Element at index i. Always checks for bounds.
at (Int64 i, Int64 j)
void fill (ConstReferenceType v)
void clear ()
Array2< T > clone ()
void copy (Span2< const T > 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< T > viewAsArray ()
 View of the array as a 1D array.
ConstArrayView< T > viewAsArray () const
 View of the array as a 1D array.
Span< T > to1DSpan ()
 View of the array as a 1D array.
Span< const T > to1DSpan () const
 View of the array as a 1D array.
 operator Array2View< T > ()
 operator ConstArray2View< T > () const
 operator Span2< const T > () const
 operator Span2< T > ()
Array2View< T > view ()
ConstArray2View< T > constView () const
Span2< T > span ()
Span2< const T > constSpan () const
Integer dim2Size () const
Integer dim1Size () const
Int64 largeDim2Size () const
Int64 largeDim1Size () const
void add (const T &value)
void resize (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_size)
 Resizes only the first dimension, leaving the second dimension unchanged.
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.
 operator Array2View< T > ()
 operator ConstArray2View< T > () const
 operator Span2< const T > () const
 operator Span2< T > ()
 operator Array2View< T > ()
 operator ConstArray2View< T > () const
 operator Span2< const T > () const
 operator Span2< T > ()

Protected Member Functions

void _initReference (const ThatClassType &rhs)
void _updateReferences () override final
 Updates references.
Integer _getNbRef () override final
 Updates references.
bool _isUseOwnMetaData () const final
 Indicates if m_md refers to m_meta_data.
void _addReference (const ThatClassType *new_ref)
 Inserts this instance into the linked list. The instance is inserted at the position of new_ref.
void _removeReference ()
 Removes this instance from the reference linked list.
void _checkFreeMemory ()
 Destroys the instance if no one references it anymore.
void _operatorEqual (const ThatClassType &rhs)
Protected Member Functions inherited from Arcane::Array2< T >
 Array2 (Int64 size1, Int64 size2)
 Creates an array of size1 * size2 elements.
 Array2 (ConstArray2View< T > rhs)
 Array2 (const Span2< const T > &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< T > &&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< T > &rhs)
void _swap (Array2< T > &rhs)
void _assignFromArray2 (const Array2< T > &rhs)
void _resizeAndCopyView (Span2< const T > rhs)
void _copyMetaData (const Array2< T > &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)
 Array2 (Int64 size1, Int64 size2)
 Creates an array of size1 * size2 elements.
 Array2 (ConstArray2View< T > rhs)
 Array2 (const Span2< const T > &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< T > &&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< T > &rhs)
void _swap (Array2< T > &rhs)
void _assignFromArray2 (const Array2< T > &rhs)
void _resizeAndCopyView (Span2< const T > rhs)
void _copyMetaData (const Array2< T > &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)

Private Member Functions

void operator= (const Array2< T > &rhs)
 Forbidden.

Private Attributes

ThatClassType * m_next = nullptr
 Next reference in the linked list.
ThatClassType * m_prev = nullptr
 Previous reference in the linked list.

Additional Inherited Members

Protected Types inherited from Arcane::Array2< T >
enum  CloneBehaviour
enum  InitBehaviour
Protected Attributes inherited from Arcane::Array2< T >
T * m_ptr
T * m_ptr

Detailed Description

template<typename T>
class Arcane::SharedArray2< T >

Shared 2D data vector with reference semantics.

a2 = a1;
a1[3][6] = 1;
a2[1][2] = 2;
SharedArray2()=default
Creates an empty array.

In the previous example, a1 and a2 refer to the same memory area, so a1[3][6] will have the same value as a2[1][2].

To have a vector that copies elements upon assignment, you must use the UniqueArray2 class.

For more information, refer to SharedArray.

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

Member Typedef Documentation

◆ BaseClassType

template<typename T>
typedef AbstractArray<T> Arcane::SharedArray2< T >::BaseClassType

◆ ConstReferenceType

template<typename T>
typedef BaseClassType::ConstReferenceType Arcane::SharedArray2< T >::ConstReferenceType

◆ ThatClassType

template<typename T>
typedef SharedArray2<T> Arcane::SharedArray2< T >::ThatClassType

Constructor & Destructor Documentation

◆ SharedArray2() [1/5]

template<typename T>
Arcane::SharedArray2< T >::SharedArray2 ( Int64 size1,
Int64 size2 )
inline

Creates an array of size1 * size2 elements.

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

◆ SharedArray2() [2/5]

template<typename T>
Arcane::SharedArray2< T >::SharedArray2 ( const ConstArray2View< T > & view)
inline

Creates an array by copying the values from the view.

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

◆ SharedArray2() [3/5]

template<typename T>
Arcane::SharedArray2< T >::SharedArray2 ( const Span2< const T > & view)
inline

Creates an array by copying the values from the view.

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

◆ SharedArray2() [4/5]

template<typename T>
Arcane::SharedArray2< T >::SharedArray2 ( const SharedArray2< T > & rhs)
inline

Creates an array referencing rhs.

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

◆ SharedArray2() [5/5]

template<typename T>
Arcane::SharedArray2< T >::SharedArray2 ( const UniqueArray2< T > & rhs)
inline

Creates an array by copying the values of rhs.

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

References Arcane::Array2< T >::copy().

Here is the call graph for this function:

◆ ~SharedArray2()

template<typename T>
Arcane::SharedArray2< T >::~SharedArray2 ( )
inlineoverride

Destroys the instance.

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

Member Function Documentation

◆ _addReference()

template<typename T>
void Arcane::SharedArray2< T >::_addReference ( const ThatClassType * new_ref)
inlineprotected

Inserts this instance into the linked list. The instance is inserted at the position of new_ref.

Precondition
m_prev==0
m_next==0;

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

◆ _checkFreeMemory()

template<typename T>
void Arcane::SharedArray2< T >::_checkFreeMemory ( )
inlineprotected

Destroys the instance if no one references it anymore.

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

◆ _getNbRef()

template<typename T>
Integer Arcane::SharedArray2< T >::_getNbRef ( )
inlinefinaloverrideprotectedvirtual

Updates references.

Reimplemented from Arcane::AbstractArray< T >.

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

◆ _initReference()

template<typename T>
void Arcane::SharedArray2< T >::_initReference ( const ThatClassType & rhs)
inlineprotected

◆ _isUseOwnMetaData()

template<typename T>
bool Arcane::SharedArray2< T >::_isUseOwnMetaData ( ) const
inlinefinalprotectedvirtual

Indicates if m_md refers to m_meta_data.

This is the case for UniqueArray and UniqueArray2 but not for SharedArray and SharedArray2.

Reimplemented from Arcane::AbstractArrayBase.

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

◆ _operatorEqual()

template<typename T>
void Arcane::SharedArray2< T >::_operatorEqual ( const ThatClassType & rhs)
inlineprotected

◆ _removeReference()

template<typename T>
void Arcane::SharedArray2< T >::_removeReference ( )
inlineprotected

Removes this instance from the reference linked list.

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

Referenced by Arcane::SharedArray2< Pointer >::~SharedArray2().

Here is the caller graph for this function:

◆ _updateReferences()

template<typename T>
void Arcane::SharedArray2< T >::_updateReferences ( )
inlinefinaloverrideprotectedvirtual

Updates references.

Reimplemented from Arcane::AbstractArray< T >.

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

◆ clone()

template<typename T>
SharedArray2< T > Arcane::SharedArray2< T >::clone ( ) const
inline

Clones the array.

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

◆ operator=() [1/4]

template<typename T>
void Arcane::SharedArray2< T >::operator= ( const ConstArray2View< T > & rhs)
inline

Copies the values of the view rhs into this instance.

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

◆ operator=() [2/4]

template<typename T>
void Arcane::SharedArray2< T >::operator= ( const SharedArray2< T > & rhs)
inline

Changes the reference of this instance to that of rhs.

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

◆ operator=() [3/4]

template<typename T>
void Arcane::SharedArray2< T >::operator= ( const Span2< const T > & rhs)
inline

Copies the values of the view rhs into this instance.

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

◆ operator=() [4/4]

template<typename T>
void Arcane::SharedArray2< T >::operator= ( const UniqueArray2< T > & rhs)
inline

Copies the values of rhs into this instance.

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

References Arcane::Array2< T >::copy().

Here is the call graph for this function:

Member Data Documentation

◆ m_next

template<typename T>
ThatClassType* Arcane::SharedArray2< T >::m_next = nullptr
private

Next reference in the linked list.

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

Referenced by Arcane::SharedArray2< Pointer >::_addReference().

◆ m_prev

template<typename T>
ThatClassType* Arcane::SharedArray2< T >::m_prev = nullptr
private

Previous reference in the linked list.

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

Referenced by Arcane::SharedArray2< Pointer >::_addReference().


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