OOFEM 3.0
Loading...
Searching...
No Matches
oofem::IntArrayF< T > Class Template Reference

#include <intarrayf.h>

Private Attributes

values
 Stored values.

Iterator for for-each loops:

T::iterator begin ()
T::iterator end ()
T::const_iterator begin () const
T::const_iterator end () const
 IntArray (int n=0)
 Constructor for sized array. Data is zeroed.
 IntArray (const IntArray &src)
 Copy constructor. Creates the array from another array.
 IntArray (IntArray &&src)
 Move constructor. Creates the array from another array.
 IntArray (std ::initializer_list< int >list)
 Initializer list constructor.
 ~IntArray ()=default
 Destructor.
IntArrayoperator= (const IntArray &src)
 Assignment operator.
IntArrayoperator= (IntArray &&src)
 Move operator.
IntArrayoperator= (std ::initializer_list< int >list)
 Assignment operator.
int & at (int i)
int at (int i) const
int & operator() (int i)
int & operator[] (int i)
const int & operator() (int i) const
const int & operator[] (int i) const
void checkBounds (int i) const
void resizeWithValues (int n, int allocChunk=0)
void resize (int n)
void clear ()
void preallocate (int futureSize)
void enumerate (int maxVal)
void followedBy (const IntArray &b, int allocChunk=0)
void followedBy (int b, int allocChunk=0)
int giveSize () const
bool isEmpty () const
bool containsOnlyZeroes () const
int findSorted (int value) const
int minimum () const
int maximum () const
void findNonzeros (const IntArray &logical)
bool containsSorted (int value) const
void insertSorted (int value, int allocChunk=0)
bool insertSortedOnce (int value, int allocChunk=0)
void eraseSorted (int value)
int findCommonValuesSorted (const IntArray &iarray, IntArray &common, int allocChunk=0) const
int findFirstIndexOf (int value) const
bool contains (int value) const
void insertOnce (int p)
void sort ()
void erase (int pos)
void add (int val)
void zero ()
 Sets all component to zero.
void printYourself () const
 Prints receiver on stdout.
void pY () const
 Abbreviation for printYourself().
void printYourself (const std::string name) const
void printYourselfToFile (const std::string filename, const bool showDimensions=true) const
bool isAllFinite () const
 Returns true if no element is NAN or infinite.
const int * givePointer () const
int * givePointer ()
contextIOResultType storeYourself (DataStream &stream) const
contextIOResultType restoreYourself (DataStream &stream)
int givePackSize (DataStream &buff) const
std::ostream & operator<< (std ::ostream &out, const IntArray &x)

Detailed Description

template<class T>
class oofem::IntArrayF< T >

Definition at line 54 of file intarrayf.h.

Constructor & Destructor Documentation

◆ ~IntArray()

template<class T>
oofem::IntArrayF< T >::~IntArray ( )
default

Destructor.

Member Function Documentation

◆ add()

template<class T>
void oofem::IntArrayF< T >::add ( int val)

Adds given scalar to all values of receiver

Parameters
valValue to add.

◆ at() [1/2]

template<class T>
int & oofem::IntArrayF< T >::at ( int i)
inline

Coefficient access function. Returns l-value of coefficient at given position of the receiver.

Parameters
iPosition of coefficient in array.
Returns
Value at position.

Definition at line 93 of file intarrayf.h.

References checkBounds(), and values.

◆ at() [2/2]

template<class T>
int oofem::IntArrayF< T >::at ( int i) const
inline

Coefficient access function. Returns value of coefficient at given position of the receiver.

Parameters
iposition of coefficient in array.
Returns
Value at position.

Definition at line 106 of file intarrayf.h.

References checkBounds(), and values.

◆ begin() [1/2]

template<class T>
T::iterator oofem::IntArrayF< T >::begin ( )
inline

Definition at line 63 of file intarrayf.h.

◆ begin() [2/2]

template<class T>
T::const_iterator oofem::IntArrayF< T >::begin ( ) const
inline

Definition at line 65 of file intarrayf.h.

◆ checkBounds()

template<class T>
void oofem::IntArrayF< T >::checkBounds ( int i) const
inline

Checks size of receiver towards requested bounds. Current implementation will call exit(1) if dimension mismatch found.

Parameters
iRequired size of receiver

Definition at line 148 of file intarrayf.h.

References giveSize(), and OOFEM_ERROR.

Referenced by at(), at(), operator[](), and operator[]().

◆ clear()

template<class T>
void oofem::IntArrayF< T >::clear ( )
inline

Clears the array (zero size).

Definition at line 174 of file intarrayf.h.

◆ contains()

template<class T>
bool oofem::IntArrayF< T >::contains ( int value) const
inline
Returns
True if receiver contains given value.

Definition at line 280 of file intarrayf.h.

References findFirstIndexOf().

◆ containsOnlyZeroes()

template<class T>
bool oofem::IntArrayF< T >::containsOnlyZeroes ( ) const

Checks if receiver is all zero.

Returns
True is receiver contains only zeroes.

◆ containsSorted()

template<class T>
bool oofem::IntArrayF< T >::containsSorted ( int value) const
inline

Checks if sorted receiver contains a given value.

Returns
True if receiver contains given value.

Definition at line 235 of file intarrayf.h.

References findSorted().

◆ end() [1/2]

template<class T>
T::iterator oofem::IntArrayF< T >::end ( )
inline

Definition at line 64 of file intarrayf.h.

◆ end() [2/2]

template<class T>
T::const_iterator oofem::IntArrayF< T >::end ( ) const
inline

Definition at line 66 of file intarrayf.h.

◆ enumerate()

template<class T>
void oofem::IntArrayF< T >::enumerate ( int maxVal)

Resizes receiver and enumerates from 1 to the maximum value given.

Parameters
maxValto enumerate to.

◆ erase()

template<class T>
void oofem::IntArrayF< T >::erase ( int pos)

Erase the element at given position (1-based index) Receiver will shrink accordingly, the values at positions (pos+1,...,size) will be moved to positions (pos,...,size-1)

Parameters
posPosition to erase.

◆ eraseSorted()

template<class T>
void oofem::IntArrayF< T >::eraseSorted ( int value)

Erase the element of given value. If the value is found receiver will shrink accordingly, while preserving a sorted state.

Parameters
valueValue to erase.

◆ findCommonValuesSorted()

template<class T>
int oofem::IntArrayF< T >::findCommonValuesSorted ( const IntArray & iarray,
IntArray & common,
int allocChunk = 0 ) const

Extracts common values in receiver and iarray. Assumes that receiver as well as iarray are sorted. The size of array common is changed accordingly.

Parameters
iarrayArray to search for values common with receiver.
commonArray of common values.
allocChunkIf reallocation needed, an additional space for allocChunk values will be allocated.
Returns
Number of common values.

References IntArray().

◆ findFirstIndexOf()

template<class T>
int oofem::IntArrayF< T >::findFirstIndexOf ( int value) const

Finds index of first occurrence of given value in array.

Parameters
valueScanned value.
Returns
Index of first value in array, otherwise zero.

Referenced by contains().

◆ findNonzeros()

template<class T>
void oofem::IntArrayF< T >::findNonzeros ( const IntArray & logical)

Finds all indices where the input array is nonzero

Parameters
logicalArray of logical values (0 = false, nonzero = true) to have index extracted.

References IntArray().

◆ findSorted()

template<class T>
int oofem::IntArrayF< T >::findSorted ( int value) const

Finds the first occurrence of given value, assuming that the receiver is sorted.

Returns
Index (1-based), if not present, 0 is returned.

Referenced by containsSorted().

◆ followedBy() [1/2]

template<class T>
void oofem::IntArrayF< T >::followedBy ( const IntArray & b,
int allocChunk = 0 )

Appends array b at the end of receiver.

Parameters
bArray to be appended at the end of receiver
allocChunkIf reallocation needed, an additional space for allocChunk values will be allocated to prevent excessive reallocation.

References IntArray().

◆ followedBy() [2/2]

template<class T>
void oofem::IntArrayF< T >::followedBy ( int b,
int allocChunk = 0 )

Appends given Number at the end of receiver.

Parameters
bvalue to be appended.
allocChunkIf reallocation needed, an additional space for allocChunk values will be allocated to prevent excessive reallocation.

◆ givePackSize()

template<class T>
int oofem::IntArrayF< T >::givePackSize ( DataStream & buff) const

Returns how much space is needed to pack receivers message.

Parameters
buffBuffer used for packing.

References IntArray().

◆ givePointer() [1/2]

template<class T>
int * oofem::IntArrayF< T >::givePointer ( )
inline

Definition at line 334 of file intarrayf.h.

References values.

◆ givePointer() [2/2]

template<class T>
const int * oofem::IntArrayF< T >::givePointer ( ) const
inline

Breaks encapsulation. Avoid using this unless absolutely necessary.

Returns
Internal pointer to stored values.

Definition at line 333 of file intarrayf.h.

References values.

◆ giveSize()

template<class T>
int oofem::IntArrayF< T >::giveSize ( ) const
inline
Returns
Size of receiver.

Definition at line 200 of file intarrayf.h.

References values.

Referenced by checkBounds().

◆ insertOnce()

template<class T>
void oofem::IntArrayF< T >::insertOnce ( int p)

Insert once (does not make any assumption about receiver state or ordering, quite inefficient). More efficient version insertSortedOnce exist.

Parameters
pValue to insert.

◆ insertSorted()

template<class T>
void oofem::IntArrayF< T >::insertSorted ( int value,
int allocChunk = 0 )

Inserts given value into a receiver, which is assumed to be sorted. The size of receiver is changed accordingly.

Parameters
valuevalue to insert.
allocChunkIf reallocation needed, an additional space for allocChunk values will be allocated.

◆ insertSortedOnce()

template<class T>
bool oofem::IntArrayF< T >::insertSortedOnce ( int value,
int allocChunk = 0 )

Inserts given value into a receiver, which is assumed to be sorted. The value is inserted only if it does not exist. The size of receiver is changed accordingly.

Parameters
valueValue to insert.
allocChunkIf reallocation needed, an additional space for allocChunk values will be allocated.
Returns
True if value is inserted, false if value is already in array.

◆ IntArray() [1/4]

template<class T>
oofem::IntArrayF< T >::IntArray ( const IntArray & src)
inline

Copy constructor. Creates the array from another array.

Definition at line 72 of file intarrayf.h.

References IntArray(), and values.

◆ IntArray() [2/4]

template<class T>
oofem::IntArrayF< T >::IntArray ( int n = 0)
inline

Constructor for sized array. Data is zeroed.

Definition at line 70 of file intarrayf.h.

References values.

Referenced by findCommonValuesSorted(), findNonzeros(), followedBy(), givePackSize(), IntArray(), IntArray(), operator=(), operator=(), and operator=().

◆ IntArray() [3/4]

template<class T>
oofem::IntArrayF< T >::IntArray ( IntArray && src)
inline

Move constructor. Creates the array from another array.

Definition at line 74 of file intarrayf.h.

References IntArray(), and values.

◆ IntArray() [4/4]

template<class T>
oofem::IntArrayF< T >::IntArray ( std ::initializer_list< int > list)
inline

Initializer list constructor.

Definition at line 76 of file intarrayf.h.

References values.

◆ isAllFinite()

template<class T>
bool oofem::IntArrayF< T >::isAllFinite ( ) const

Returns true if no element is NAN or infinite.

◆ isEmpty()

template<class T>
bool oofem::IntArrayF< T >::isEmpty ( ) const
inline

Checks if receiver is empty (i.e., zero sized).

Returns
True is size is zero.

Definition at line 205 of file intarrayf.h.

References values.

◆ maximum()

template<class T>
int oofem::IntArrayF< T >::maximum ( ) const

Finds the maximum component in the array.

Returns
Maximum of array or prints error is array is empty.

◆ minimum()

template<class T>
int oofem::IntArrayF< T >::minimum ( ) const

Finds the minimum component in the array.

Returns
Minimum of array or prints error is array is empty.

◆ operator()() [1/2]

template<class T>
int & oofem::IntArrayF< T >::operator() ( int i)
inline

Coefficient access function. Returns value of coefficient at given position of the receiver. Provides 0-based indexing access.

Parameters
iPosition of coefficient in array.
Returns
Value at position.

Definition at line 119 of file intarrayf.h.

References operator[]().

◆ operator()() [2/2]

template<class T>
const int & oofem::IntArrayF< T >::operator() ( int i) const
inline

Coefficient access function. Returns value of coefficient at given position of the receiver. Provides 0-based indexing access.

Parameters
iposition of coefficient in array.
Returns
Value at position.

Definition at line 133 of file intarrayf.h.

References operator[]().

◆ operator=() [1/3]

template<class T>
IntArray & oofem::IntArrayF< T >::operator= ( const IntArray & src)
inline

Assignment operator.

Definition at line 81 of file intarrayf.h.

References IntArray(), oofem::IntArray::values, and values.

◆ operator=() [2/3]

template<class T>
IntArray & oofem::IntArrayF< T >::operator= ( IntArray && src)
inline

Move operator.

Definition at line 83 of file intarrayf.h.

References IntArray(), and values.

◆ operator=() [3/3]

template<class T>
IntArray & oofem::IntArrayF< T >::operator= ( std ::initializer_list< int > list)
inline

Assignment operator.

Definition at line 85 of file intarrayf.h.

References IntArray(), and values.

◆ operator[]() [1/2]

template<class T>
int & oofem::IntArrayF< T >::operator[] ( int i)
inline

Definition at line 120 of file intarrayf.h.

References checkBounds(), and values.

Referenced by operator()(), and operator()().

◆ operator[]() [2/2]

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

Definition at line 134 of file intarrayf.h.

References checkBounds(), and values.

◆ preallocate()

template<class T>
void oofem::IntArrayF< T >::preallocate ( int futureSize)

Preallocates receiver to given futureSize if larger then allocatedSize.

Parameters
futureSizeSize to be allocated.

◆ printYourself() [1/2]

template<class T>
void oofem::IntArrayF< T >::printYourself ( ) const

Prints receiver on stdout.

◆ printYourself() [2/2]

template<class T>
void oofem::IntArrayF< T >::printYourself ( const std::string name) const

Prints receiver on stdout with custom name.

Parameters
nameDisplay name of reciever.

◆ printYourselfToFile()

template<class T>
void oofem::IntArrayF< T >::printYourselfToFile ( const std::string filename,
const bool showDimensions = true ) const

Print receiver to file

Parameters
filenameName of recieving file.
showDimensionsDetermins if dimesions should be included in output

◆ pY()

template<class T>
void oofem::IntArrayF< T >::pY ( ) const

Abbreviation for printYourself().

◆ resize()

template<class T>
void oofem::IntArrayF< T >::resize ( int n)

Checks size of receiver towards requested bounds. Data is always zeroed.

Parameters
nNew size of array.

◆ resizeWithValues()

template<class T>
void oofem::IntArrayF< T >::resizeWithValues ( int n,
int allocChunk = 0 )

Checks size of receiver towards requested bounds. If dimension mismatch, size is adjusted accordingly and memory is copied over.

Parameters
nNew size of array.
allocChunkIf reallocation needed, an additional space for allocChunk values will be allocated to prevent excessive reallocation.

◆ restoreYourself()

template<class T>
contextIOResultType oofem::IntArrayF< T >::restoreYourself ( DataStream & stream)

Restores array from image on stream.

◆ sort()

template<class T>
void oofem::IntArrayF< T >::sort ( )

Sorts array.

◆ storeYourself()

template<class T>
contextIOResultType oofem::IntArrayF< T >::storeYourself ( DataStream & stream) const

Stores array to output stream.

◆ zero()

template<class T>
void oofem::IntArrayF< T >::zero ( )

Sets all component to zero.

◆ operator<<

template<class T>
std::ostream & operator<< ( std ::ostream & out,
const IntArray & x )
friend

Definition at line 375 of file intarray.C.

Member Data Documentation

◆ values

template<class T>
T oofem::IntArrayF< T >::values
private

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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011