MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::Array< T > Class Template Reference

#include <array.hpp>

Public Types

using value_type = T
 Type alias for stl.
 
using reference = T&
 Type alias for stl.
 
using const_reference = const T&
 Type alias for stl.
 

Public Member Functions

 Array ()
 Creates an empty array.
 
 Array (MemoryType mt)
 Creates an empty array with a given MemoryType.
 
 Array (int asize)
 Creates array of asize elements.
 
 Array (int asize, MemoryType mt)
 Creates array of asize elements with a given MemoryType.
 
 Array (T *data_, int asize, bool own_data=false)
 Creates array using an externally allocated host pointer data_ to asize elements. If own_data is true, the array takes ownership of the pointer.
 
 Array (const Array &src)
 Copy constructor: deep copy from src.
 
template<typename CT >
 Array (const Array< CT > &src)
 Copy constructor (deep copy) from 'src', an Array of convertible type.
 
template<typename CT , int N>
 Array (const CT(&values)[N])
 Construct an Array from a C-style array of static length.
 
template<typename CT , typename std::enable_if< std::is_convertible< CT, T >::value, bool >::type = true>
 Array (std::initializer_list< CT > values)
 Construct an Array from a braced initializer list of convertible type.
 
 Array (Array< T > &&src)
 Move constructor ("steals" data from 'src')
 
 ~Array ()
 Destructor.
 
Array< T > & operator= (const Array< T > &src)
 Copy assignment operator: deep copy from 'src'.
 
Array< T > & operator= (Array< T > &&src)
 Move assignment operator.
 
template<typename CT >
Arrayoperator= (const Array< CT > &src)
 Assignment operator (deep copy) from src, an Array of convertible type.
 
void Swap (Array &other)
 Swap the contents of the Array with other.
 
 operator T* ()
 Return the data as 'T *'.
 
 operator const T * () const
 Return the data as 'const T *'.
 
T * GetData ()
 Returns the data.
 
const T * GetData () const
 Returns the data.
 
Memory< T > & GetMemory ()
 Return a reference to the Memory object used by the Array.
 
const Memory< T > & GetMemory () const
 Return a reference to the Memory object used by the Array, const version.
 
bool UseDevice () const
 Return the device flag of the Memory object used by the Array.
 
bool OwnsData () const
 Return true if the data will be deleted by the Array.
 
void StealData (T **p)
 Changes the ownership of the data.
 
void LoseData ()
 NULL-ifies the data.
 
void MakeDataOwner () const
 Make the Array own the data.
 
int Size () const
 Return the logical size of the array.
 
void SetSize (int nsize)
 Change the logical size of the array, keep existing entries.
 
void SetSize (int nsize, const T &initval)
 Same as SetSize(int) plus initialize new entries with 'initval'.
 
void SetSize (int nsize, MemoryType mt)
 Resize the array to size nsize using MemoryType mt. Note that unlike the other versions of SetSize(), the current content of the array is not preserved.
 
int Capacity () const
 
void Reserve (int capacity)
 Ensures that the allocated size is at least the given size.
 
T & operator[] (int i)
 Reference access to the ith element.
 
const T & operator[] (int i) const
 Const reference access to the ith element.
 
int Append (const T &el)
 Append element 'el' to array, resize if necessary.
 
void push_back (const T &el)
 STL-like push_back. Append element 'el' to array, resize if necessary.
 
int Append (const T *els, int nels)
 Append another array to this array, resize if necessary.
 
int Append (const Array< T > &els)
 Append another array to this array, resize if necessary.
 
int Prepend (const T &el)
 Prepend an 'el' to the array, resize if necessary.
 
T & Last ()
 Return the last element in the array.
 
const T & Last () const
 Return the last element in the array.
 
int Union (const T &el)
 Append element when it is not yet in the array, return index.
 
int Find (const T &el) const
 Return the first index where 'el' is found; return -1 if not found.
 
int FindSorted (const T &el) const
 Do bisection search for 'el' in a sorted array; return -1 if not found.
 
void DeleteLast ()
 Delete the last entry of the array.
 
void DeleteFirst (const T &el)
 Delete the first entry with value == 'el'.
 
void DeleteAt (const Array< int > &indices)
 Delete entries at indices, and resize.
 
void DeleteAll ()
 Delete the whole array.
 
void ShrinkToFit ()
 Reduces the capacity of the array to exactly match the current size.
 
void Copy (Array &copy) const
 Create a copy of the internal array to the provided copy.
 
void MakeRef (T *data_, int size_, bool own_data=false)
 Make this Array a reference to a pointer.
 
void MakeRef (T *data_, int size, MemoryType mt, bool own_data)
 Make this Array a reference to a pointer.
 
void MakeRef (const Array &master)
 Make this Array a reference to 'master'.
 
void NewMemoryAndSize (const Memory< T > &mem, int s, bool own_mem)
 Reset the Array to use the given external Memory mem and size s.
 
template<typename I >
void Permute (I &&indices)
 Permute the array using the provided indices. Sorts the indices variable in the process, thereby destroying the permutation. The rvalue reference is to be used when this destruction is allowed, whilst the const reference preserves at the cost of duplication.
 
template<typename I >
void Permute (const I &indices)
 
void GetSubArray (int offset, int sa_size, Array< T > &sa) const
 Copy sub array starting from offset out to the provided sa.
 
void Print (std::ostream &out=mfem::out, int width=4) const
 Prints array to stream with width elements per row.
 
void Save (std::ostream &out, int fmt=0) const
 Save the Array to the stream out using the format fmt. The format fmt can be:
 
void Load (std::istream &in, int fmt=0)
 Read an Array from the stream in using format fmt. The format fmt can be:
 
void Load (int new_size, std::istream &in)
 Set the Array size to new_size and read that many entries from the stream in.
 
Max () const
 Find the maximal element in the array, using the comparison operator < for class T.
 
Min () const
 Find the minimal element in the array, using the comparison operator < for class T.
 
void Sort ()
 Sorts the array in ascending order. This requires operator< to be defined for T.
 
template<class Compare >
void Sort (Compare cmp)
 Sorts the array in ascending order using the supplied comparison function object.
 
void Unique ()
 Removes duplicities from a sorted array. This requires operator== to be defined for T.
 
int IsSorted () const
 Return 1 if the array is sorted from lowest to highest. Otherwise return 0.
 
bool IsEmpty () const
 Does the Array have Size zero.
 
bool IsConstant () const
 Return true if all entries of the array are the same.
 
void PartialSum ()
 Fill the entries of the array with the cumulative sum of the entries.
 
void Abs ()
 Replace each entry of the array with its absolute value.
 
Sum () const
 Return the sum of all the array entries using the '+'' operator for class 'T'.
 
void operator= (const T &a)
 Set all entries of the array to the provided constant.
 
void Assign (const T *)
 Copy data from a pointer. 'Size()' elements are copied.
 
template<typename U >
void CopyTo (U *dest)
 STL-like copyTo dest from begin to end.
 
template<typename U >
void CopyFrom (const U *src)
 Copy from src into this array. Copies enough entries to fill the Capacity size of this array. Careful this does not update the Size to match this Capacity after this.
 
T * begin ()
 STL-like begin. Returns pointer to the first element of the array.
 
T * end ()
 STL-like end. Returns pointer after the last element of the array.
 
const T * begin () const
 STL-like begin. Returns const pointer to the first element of the array.
 
const T * end () const
 STL-like end. Returns const pointer after the last element of the array.
 
std::size_t MemoryUsage () const
 Returns the number of bytes allocated for the array including any reserve.
 
const T * Read (bool on_dev=true) const
 Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
 
const T * HostRead () const
 Shortcut for mfem::Read(a.GetMemory(), a.Size(), false).
 
T * Write (bool on_dev=true)
 Shortcut for mfem::Write(a.GetMemory(), a.Size(), on_dev).
 
T * HostWrite ()
 Shortcut for mfem::Write(a.GetMemory(), a.Size(), false).
 
T * ReadWrite (bool on_dev=true)
 Shortcut for mfem::ReadWrite(a.GetMemory(), a.Size(), on_dev).
 
T * HostReadWrite ()
 Shortcut for mfem::ReadWrite(a.GetMemory(), a.Size(), false).
 
template<typename CT >
Array< T > & operator= (const Array< CT > &src)
 

Protected Member Functions

void GrowSize (int minsize)
 

Protected Attributes

Memory< T > data
 Pointer to data.
 
int size
 Size of the array.
 

Detailed Description

template<class T>
class mfem::Array< T >

Abstract data type Array.

Array<T> is an automatically increasing array containing elements of the generic type T, which must be a trivial type, see std::is_trivial. The allocated size may be larger then the logical size of the array. The elements can be accessed by the [] operator, the range is 0 to size-1.

Definition at line 47 of file array.hpp.

Member Typedef Documentation

◆ const_reference

template<class T >
using mfem::Array< T >::const_reference = const T&

Type alias for stl.

Definition at line 62 of file array.hpp.

◆ reference

template<class T >
using mfem::Array< T >::reference = T&

Type alias for stl.

Definition at line 61 of file array.hpp.

◆ value_type

template<class T >
using mfem::Array< T >::value_type = T

Type alias for stl.

Definition at line 60 of file array.hpp.

Constructor & Destructor Documentation

◆ Array() [1/10]

template<class T >
mfem::Array< T >::Array ( )
inline

Creates an empty array.

Definition at line 65 of file array.hpp.

◆ Array() [2/10]

template<class T >
mfem::Array< T >::Array ( MemoryType mt)
inline

Creates an empty array with a given MemoryType.

Definition at line 68 of file array.hpp.

◆ Array() [3/10]

template<class T >
mfem::Array< T >::Array ( int asize)
inlineexplicit

Creates array of asize elements.

Definition at line 71 of file array.hpp.

◆ Array() [4/10]

template<class T >
mfem::Array< T >::Array ( int asize,
MemoryType mt )
inline

Creates array of asize elements with a given MemoryType.

Definition at line 75 of file array.hpp.

◆ Array() [5/10]

template<class T >
mfem::Array< T >::Array ( T * data_,
int asize,
bool own_data = false )
inline

Creates array using an externally allocated host pointer data_ to asize elements. If own_data is true, the array takes ownership of the pointer.

When own_data is true, the pointer data_ must be allocated with MemoryType given by MemoryManager::GetHostMemoryType().

Definition at line 84 of file array.hpp.

◆ Array() [6/10]

template<class T >
mfem::Array< T >::Array ( const Array< T > & src)
inline

Copy constructor: deep copy from src.

This method supports source arrays using any MemoryType.

Definition at line 754 of file array.hpp.

◆ Array() [7/10]

template<typename T >
template<typename CT >
mfem::Array< T >::Array ( const Array< CT > & src)
inline

Copy constructor (deep copy) from 'src', an Array of convertible type.

Definition at line 763 of file array.hpp.

◆ Array() [8/10]

template<typename T >
template<typename CT , int N>
mfem::Array< T >::Array ( const CT(&) values[N])
inlineexplicit

Construct an Array from a C-style array of static length.

Definition at line 779 of file array.hpp.

◆ Array() [9/10]

template<typename T >
template<typename CT , typename std::enable_if< std::is_convertible< CT, T >::value, bool >::type >
mfem::Array< T >::Array ( std::initializer_list< CT > values)
inlineexplicit

Construct an Array from a braced initializer list of convertible type.

Definition at line 773 of file array.hpp.

◆ Array() [10/10]

template<class T >
mfem::Array< T >::Array ( Array< T > && src)
inline

Move constructor ("steals" data from 'src')

Definition at line 105 of file array.hpp.

◆ ~Array()

template<class T >
mfem::Array< T >::~Array ( )
inline

Destructor.

Definition at line 111 of file array.hpp.

Member Function Documentation

◆ Abs()

template<class T >
void mfem::Array< T >::Abs ( )

Replace each entry of the array with its absolute value.

Definition at line 115 of file array.cpp.

◆ Append() [1/3]

template<class T >
int mfem::Array< T >::Append ( const Array< T > & els)
inline

Append another array to this array, resize if necessary.

Definition at line 203 of file array.hpp.

◆ Append() [2/3]

template<class T >
int mfem::Array< T >::Append ( const T & el)
inline

Append element 'el' to array, resize if necessary.

Definition at line 912 of file array.hpp.

◆ Append() [3/3]

template<class T >
int mfem::Array< T >::Append ( const T * els,
int nels )
inline

Append another array to this array, resize if necessary.

Definition at line 920 of file array.hpp.

◆ Assign()

template<class T >
void mfem::Array< T >::Assign ( const T * p)
inline

Copy data from a pointer. 'Size()' elements are copied.

Definition at line 1112 of file array.hpp.

◆ begin() [1/2]

template<class T >
T * mfem::Array< T >::begin ( )
inline

STL-like begin. Returns pointer to the first element of the array.

Definition at line 366 of file array.hpp.

◆ begin() [2/2]

template<class T >
const T * mfem::Array< T >::begin ( ) const
inline

STL-like begin. Returns const pointer to the first element of the array.

Definition at line 372 of file array.hpp.

◆ Capacity()

template<class T >
int mfem::Array< T >::Capacity ( ) const
inline

Maximum number of entries the array can store without allocating more memory.

Definition at line 181 of file array.hpp.

◆ Copy()

template<typename T >
void mfem::Array< T >::Copy ( Array< T > & copy) const
inline

Create a copy of the internal array to the provided copy.

Definition at line 1042 of file array.hpp.

◆ CopyFrom()

template<class T >
template<typename U >
void mfem::Array< T >::CopyFrom ( const U * src)
inline

Copy from src into this array. Copies enough entries to fill the Capacity size of this array. Careful this does not update the Size to match this Capacity after this.

Definition at line 358 of file array.hpp.

◆ CopyTo()

template<class T >
template<typename U >
void mfem::Array< T >::CopyTo ( U * dest)
inline

STL-like copyTo dest from begin to end.

Definition at line 352 of file array.hpp.

◆ DeleteAll()

template<class T >
void mfem::Array< T >::DeleteAll ( )
inline

Delete the whole array.

Definition at line 1033 of file array.hpp.

◆ DeleteAt()

template<class T >
void mfem::Array< T >::DeleteAt ( const Array< int > & indices)
inline

Delete entries at indices, and resize.

Definition at line 1007 of file array.hpp.

◆ DeleteFirst()

template<class T >
void mfem::Array< T >::DeleteFirst ( const T & el)
inline

Delete the first entry with value == 'el'.

Definition at line 990 of file array.hpp.

◆ DeleteLast()

template<class T >
void mfem::Array< T >::DeleteLast ( )
inline

Delete the last entry of the array.

Definition at line 224 of file array.hpp.

◆ end() [1/2]

template<class T >
T * mfem::Array< T >::end ( )
inline

STL-like end. Returns pointer after the last element of the array.

Definition at line 369 of file array.hpp.

◆ end() [2/2]

template<class T >
const T * mfem::Array< T >::end ( ) const
inline

STL-like end. Returns const pointer after the last element of the array.

Definition at line 375 of file array.hpp.

◆ Find()

template<class T >
int mfem::Array< T >::Find ( const T & el) const
inline

Return the first index where 'el' is found; return -1 if not found.

Definition at line 971 of file array.hpp.

◆ FindSorted()

template<class T >
int mfem::Array< T >::FindSorted ( const T & el) const
inline

Do bisection search for 'el' in a sorted array; return -1 if not found.

Definition at line 981 of file array.hpp.

◆ GetData() [1/2]

template<class T >
T * mfem::Array< T >::GetData ( )
inline

Returns the data.

Definition at line 140 of file array.hpp.

◆ GetData() [2/2]

template<class T >
const T * mfem::Array< T >::GetData ( ) const
inline

Returns the data.

Definition at line 142 of file array.hpp.

◆ GetMemory() [1/2]

template<class T >
Memory< T > & mfem::Array< T >::GetMemory ( )
inline

Return a reference to the Memory object used by the Array.

Definition at line 145 of file array.hpp.

◆ GetMemory() [2/2]

template<class T >
const Memory< T > & mfem::Array< T >::GetMemory ( ) const
inline

Return a reference to the Memory object used by the Array, const version.

Definition at line 148 of file array.hpp.

◆ GetSubArray()

template<class T >
void mfem::Array< T >::GetSubArray ( int offset,
int sa_size,
Array< T > & sa ) const
inline

Copy sub array starting from offset out to the provided sa.

Definition at line 1093 of file array.hpp.

◆ GrowSize()

template<class T >
void mfem::Array< T >::GrowSize ( int minsize)
inlineprotected

Definition at line 792 of file array.hpp.

◆ HostRead()

template<class T >
const T * mfem::Array< T >::HostRead ( ) const
inline

Shortcut for mfem::Read(a.GetMemory(), a.Size(), false).

Definition at line 385 of file array.hpp.

◆ HostReadWrite()

template<class T >
T * mfem::Array< T >::HostReadWrite ( )
inline

Shortcut for mfem::ReadWrite(a.GetMemory(), a.Size(), false).

Definition at line 401 of file array.hpp.

◆ HostWrite()

template<class T >
T * mfem::Array< T >::HostWrite ( )
inline

Shortcut for mfem::Write(a.GetMemory(), a.Size(), false).

Definition at line 393 of file array.hpp.

◆ IsConstant()

template<class T >
bool mfem::Array< T >::IsConstant ( ) const

Return true if all entries of the array are the same.

Definition at line 158 of file array.cpp.

◆ IsEmpty()

template<class T >
bool mfem::Array< T >::IsEmpty ( ) const
inline

Does the Array have Size zero.

Definition at line 330 of file array.hpp.

◆ IsSorted()

template<class T >
int mfem::Array< T >::IsSorted ( ) const

Return 1 if the array is sorted from lowest to highest. Otherwise return 0.

Definition at line 141 of file array.cpp.

◆ Last() [1/2]

template<class T >
T & mfem::Array< T >::Last ( )
inline

Return the last element in the array.

Definition at line 945 of file array.hpp.

◆ Last() [2/2]

template<class T >
const T & mfem::Array< T >::Last ( ) const
inline

Return the last element in the array.

Definition at line 952 of file array.hpp.

◆ Load() [1/2]

template<class T >
void mfem::Array< T >::Load ( int new_size,
std::istream & in )
inline

Set the Array size to new_size and read that many entries from the stream in.

Definition at line 300 of file array.hpp.

◆ Load() [2/2]

template<class T >
void mfem::Array< T >::Load ( std::istream & in,
int fmt = 0 )

Read an Array from the stream in using format fmt. The format fmt can be:

0 - read the size then the entries 1 - read Size() entries

Definition at line 54 of file array.cpp.

◆ LoseData()

template<class T >
void mfem::Array< T >::LoseData ( )
inline

NULL-ifies the data.

Definition at line 160 of file array.hpp.

◆ MakeDataOwner()

template<class T >
void mfem::Array< T >::MakeDataOwner ( ) const
inline

Make the Array own the data.

Definition at line 163 of file array.hpp.

◆ MakeRef() [1/3]

template<class T >
void mfem::Array< T >::MakeRef ( const Array< T > & master)
inline

Make this Array a reference to 'master'.

Definition at line 1069 of file array.hpp.

◆ MakeRef() [2/3]

template<class T >
void mfem::Array< T >::MakeRef ( T * data_,
int size,
MemoryType mt,
bool own_data )
inline

Make this Array a reference to a pointer.

When own_data is true, the pointer data_ must be allocated with MemoryType given by mt.

Definition at line 1061 of file array.hpp.

◆ MakeRef() [3/3]

template<class T >
void mfem::Array< T >::MakeRef ( T * data_,
int size_,
bool own_data = false )
inline

Make this Array a reference to a pointer.

When own_data is true, the pointer data_ must be allocated with MemoryType given by MemoryManager::GetHostMemoryType().

Definition at line 1053 of file array.hpp.

◆ Max()

template<class T >
T mfem::Array< T >::Max ( ) const

Find the maximal element in the array, using the comparison operator < for class T.

Definition at line 69 of file array.cpp.

◆ MemoryUsage()

template<class T >
std::size_t mfem::Array< T >::MemoryUsage ( ) const
inline

Returns the number of bytes allocated for the array including any reserve.

Definition at line 378 of file array.hpp.

◆ Min()

template<class T >
T mfem::Array< T >::Min ( ) const

Find the minimal element in the array, using the comparison operator < for class T.

Definition at line 86 of file array.cpp.

◆ NewMemoryAndSize()

template<class T >
void mfem::Array< T >::NewMemoryAndSize ( const Memory< T > & mem,
int s,
bool own_mem )
inline

Reset the Array to use the given external Memory mem and size s.

If own_mem is false, the Array will not own any of the pointers of mem.

Note that when own_mem is true, the mem object can be destroyed immediately by the caller but mem.Delete() should NOT be called since the Array object takes ownership of all pointers owned by mem.

Definition at line 1077 of file array.hpp.

◆ operator const T *()

template<class T >
mfem::Array< T >::operator const T * ( ) const
inline

Return the data as 'const T *'.

Definition at line 137 of file array.hpp.

◆ operator T*()

template<class T >
mfem::Array< T >::operator T* ( )
inline

Return the data as 'T *'.

Definition at line 134 of file array.hpp.

◆ operator=() [1/5]

template<class T >
Array< T > & mfem::Array< T >::operator= ( Array< T > && src)
inline

Move assignment operator.

Definition at line 117 of file array.hpp.

◆ operator=() [2/5]

template<class T >
template<typename CT >
Array & mfem::Array< T >::operator= ( const Array< CT > & src)
inline

Assignment operator (deep copy) from src, an Array of convertible type.

◆ operator=() [3/5]

template<class T >
template<typename CT >
Array< T > & mfem::Array< T >::operator= ( const Array< CT > & src)
inline

Definition at line 832 of file array.hpp.

◆ operator=() [4/5]

template<class T >
Array< T > & mfem::Array< T >::operator= ( const Array< T > & src)
inline

Copy assignment operator: deep copy from 'src'.

Definition at line 114 of file array.hpp.

◆ operator=() [5/5]

template<class T >
void mfem::Array< T >::operator= ( const T & a)
inline

Set all entries of the array to the provided constant.

Definition at line 1103 of file array.hpp.

◆ operator[]() [1/2]

template<class T >
T & mfem::Array< T >::operator[] ( int i)
inline

Reference access to the ith element.

Definition at line 896 of file array.hpp.

◆ operator[]() [2/2]

template<class T >
const T & mfem::Array< T >::operator[] ( int i) const
inline

Const reference access to the ith element.

Definition at line 904 of file array.hpp.

◆ OwnsData()

template<class T >
bool mfem::Array< T >::OwnsData ( ) const
inline

Return true if the data will be deleted by the Array.

Definition at line 154 of file array.hpp.

◆ PartialSum()

template<class T >
void mfem::Array< T >::PartialSum ( )

Fill the entries of the array with the cumulative sum of the entries.

Definition at line 104 of file array.cpp.

◆ Permute() [1/2]

template<class T >
template<typename I >
void mfem::Array< T >::Permute ( const I & indices)
inline

Definition at line 274 of file array.hpp.

◆ Permute() [2/2]

template<typename T >
template<typename I >
void mfem::Array< T >::Permute ( I && indices)
inline

Permute the array using the provided indices. Sorts the indices variable in the process, thereby destroying the permutation. The rvalue reference is to be used when this destruction is allowed, whilst the const reference preserves at the cost of duplication.

Parameters
indicesThe indices of the ordering. data[i] = data[indices[i]].

Definition at line 815 of file array.hpp.

◆ Prepend()

template<class T >
int mfem::Array< T >::Prepend ( const T & el)
inline

Prepend an 'el' to the array, resize if necessary.

Definition at line 933 of file array.hpp.

◆ Print()

template<class T >
void mfem::Array< T >::Print ( std::ostream & out = mfem::out,
int width = 4 ) const

Prints array to stream with width elements per row.

Definition at line 24 of file array.cpp.

◆ push_back()

template<class T >
void mfem::Array< T >::push_back ( const T & el)
inline

STL-like push_back. Append element 'el' to array, resize if necessary.

Definition at line 197 of file array.hpp.

◆ Read()

template<class T >
const T * mfem::Array< T >::Read ( bool on_dev = true) const
inline

Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).

Definition at line 381 of file array.hpp.

◆ ReadWrite()

template<class T >
T * mfem::Array< T >::ReadWrite ( bool on_dev = true)
inline

Shortcut for mfem::ReadWrite(a.GetMemory(), a.Size(), on_dev).

Definition at line 397 of file array.hpp.

◆ Reserve()

template<class T >
void mfem::Array< T >::Reserve ( int capacity)
inline

Ensures that the allocated size is at least the given size.

Definition at line 184 of file array.hpp.

◆ Save()

template<class T >
void mfem::Array< T >::Save ( std::ostream & out,
int fmt = 0 ) const

Save the Array to the stream out using the format fmt. The format fmt can be:

0 - write the size followed by all entries 1 - write only the entries

Definition at line 41 of file array.cpp.

◆ SetSize() [1/3]

template<class T >
void mfem::Array< T >::SetSize ( int nsize)
inline

Change the logical size of the array, keep existing entries.

Definition at line 840 of file array.hpp.

◆ SetSize() [2/3]

template<class T >
void mfem::Array< T >::SetSize ( int nsize,
const T & initval )
inline

Same as SetSize(int) plus initialize new entries with 'initval'.

Definition at line 851 of file array.hpp.

◆ SetSize() [3/3]

template<class T >
void mfem::Array< T >::SetSize ( int nsize,
MemoryType mt )
inline

Resize the array to size nsize using MemoryType mt. Note that unlike the other versions of SetSize(), the current content of the array is not preserved.

Definition at line 869 of file array.hpp.

◆ ShrinkToFit()

template<typename T >
void mfem::Array< T >::ShrinkToFit ( )
inline

Reduces the capacity of the array to exactly match the current size.

Definition at line 803 of file array.hpp.

◆ Size()

template<class T >
int mfem::Array< T >::Size ( ) const
inline

Return the logical size of the array.

Definition at line 166 of file array.hpp.

◆ Sort() [1/2]

template<class T >
void mfem::Array< T >::Sort ( )
inline

Sorts the array in ascending order. This requires operator< to be defined for T.

Definition at line 312 of file array.hpp.

◆ Sort() [2/2]

template<class T >
template<class Compare >
void mfem::Array< T >::Sort ( Compare cmp)
inline

Sorts the array in ascending order using the supplied comparison function object.

Definition at line 316 of file array.hpp.

◆ StealData()

template<class T >
void mfem::Array< T >::StealData ( T ** p)
inline

Changes the ownership of the data.

Definition at line 157 of file array.hpp.

◆ Sum()

template<class T >
T mfem::Array< T >::Sum ( ) const

Return the sum of all the array entries using the '+'' operator for class 'T'.

Definition at line 129 of file array.cpp.

◆ Swap()

template<class T >
void mfem::Array< T >::Swap ( Array< T > & other)
inline

Swap the contents of the Array with other.

Implemented without using move assignment, avoiding DeleteAll() calls.

Definition at line 785 of file array.hpp.

◆ Union()

template<class T >
int mfem::Array< T >::Union ( const T & el)
inline

Append element when it is not yet in the array, return index.

Definition at line 959 of file array.hpp.

◆ Unique()

template<class T >
void mfem::Array< T >::Unique ( )
inline

Removes duplicities from a sorted array. This requires operator== to be defined for T.

Definition at line 320 of file array.hpp.

◆ UseDevice()

template<class T >
bool mfem::Array< T >::UseDevice ( ) const
inline

Return the device flag of the Memory object used by the Array.

Definition at line 151 of file array.hpp.

◆ Write()

template<class T >
T * mfem::Array< T >::Write ( bool on_dev = true)
inline

Shortcut for mfem::Write(a.GetMemory(), a.Size(), on_dev).

Definition at line 389 of file array.hpp.

Member Data Documentation

◆ data

template<class T >
Memory<T> mfem::Array< T >::data
protected

Pointer to data.

Definition at line 51 of file array.hpp.

◆ size

template<class T >
int mfem::Array< T >::size
protected

Size of the array.

Definition at line 53 of file array.hpp.


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