Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ogdf::Array2D< E > Class Template Reference

The parameterized class Array2D implements dynamic two-dimensional arrays. More...

#include <ogdf/basic/Array2D.h>

Public Member Functions

 Array2D ()
 Creates a two-dimensional array with empty index set. More...
 
 Array2D (Array2D< E > &&A)
 Creates a two-dimensional array containing the elements of A (move semantics). More...
 
 Array2D (const Array2D< E > &A)
 Creates a two-dimensional array that is a copy of A. More...
 
 Array2D (int a, int b, int c, int d)
 Creates a two-dimensional array with index set [a, ..., b]*[c, ..., d]. More...
 
 Array2D (int a, int b, int c, int d, const E &x)
 Creates a two-dimensional array with index set [a, ..., b]*[c, ..., d] and initailizes all elements with x. More...
 
 ~Array2D ()
 Destructor. More...
 
float det () const
 Returns the determinant of the matrix. More...
 
void fill (const E &x)
 Sets all elements to x. More...
 
int high1 () const
 Returns the maximal array index in dimension 1. More...
 
int high2 () const
 Returns the maximal array index in dimension 2. More...
 
void init ()
 Reinitializes the array to an array with empty index set. More...
 
void init (int a, int b, int c, int d)
 Reinitializes the array to an array with index set [a, ..., b]*[c, ..., d]. More...
 
void init (int a, int b, int c, int d, const E &x)
 Reinitializes the array to an array with index set [a, ..., b]*[c, ..., d] and initializes all entries with x. More...
 
int low1 () const
 Returns the minimal array index in dimension 1. More...
 
int low2 () const
 Returns the minimal array index in dimension 2. More...
 
E & operator() (int i, int j)
 Returns a reference to the element with index (i,j). More...
 
const E & operator() (int i, int j) const
 Returns a reference to the element with index (i,j). More...
 
Array2D< E > & operator= (Array2D< E > &&A)
 Assignment operator (move semantics). More...
 
Array2D< E > & operator= (const Array2D< E > &array2)
 Assignment operator. More...
 
int size () const
 Returns the size (number of elements) of the array. More...
 
int size1 () const
 Returns the length of the index interval (number of entries) in dimension 1. More...
 
int size2 () const
 Returns the length of the index interval (number of entries) in dimension 2. More...
 

Private Member Functions

void construct (int a, int b, int c, int d)
 Constructs the array with index set [a, ..., b]*[c, ..., d]. More...
 
void copy (const Array2D< E > &array2)
 Copy array2. More...
 
void deconstruct ()
 Call destructor of all elements. More...
 
void initialize ()
 Initializes the array with default constructor of E. More...
 
void initialize (const E &x)
 Initializes the array with x. More...
 

Private Attributes

int m_a
 The lowest index in dimension 1. More...
 
int m_b
 The highest index in dimension 1. More...
 
int m_c
 The lowest index in dimension 2. More...
 
int m_d
 The highest index in dimension 2. More...
 
int m_lenDim2
 The number of elements in dimension 2. More...
 
E * m_pStart
 The real start of the array (address of A[low1,low2]). More...
 
E * m_pStop
 Successor of last element (address of A[high1,high2+1]). More...
 
E * m_vpStart
 The virtual start of the array (address of A[0,0]). More...
 

Detailed Description

template<class E>
class ogdf::Array2D< E >

The parameterized class Array2D implements dynamic two-dimensional arrays.

Template Parameters
Edenotes the element type.

Definition at line 53 of file Array2D.h.

Constructor & Destructor Documentation

◆ Array2D() [1/5]

template<class E >
ogdf::Array2D< E >::Array2D ( )
inline

Creates a two-dimensional array with empty index set.

Definition at line 58 of file Array2D.h.

◆ Array2D() [2/5]

template<class E >
ogdf::Array2D< E >::Array2D ( int  a,
int  b,
int  c,
int  d 
)
inline

Creates a two-dimensional array with index set [a, ..., b]*[c, ..., d].

Definition at line 61 of file Array2D.h.

◆ Array2D() [3/5]

template<class E >
ogdf::Array2D< E >::Array2D ( int  a,
int  b,
int  c,
int  d,
const E &  x 
)
inline

Creates a two-dimensional array with index set [a, ..., b]*[c, ..., d] and initailizes all elements with x.

Definition at line 67 of file Array2D.h.

◆ Array2D() [4/5]

template<class E >
ogdf::Array2D< E >::Array2D ( const Array2D< E > &  A)
inline

Creates a two-dimensional array that is a copy of A.

Definition at line 73 of file Array2D.h.

◆ Array2D() [5/5]

template<class E >
ogdf::Array2D< E >::Array2D ( Array2D< E > &&  A)
inline

Creates a two-dimensional array containing the elements of A (move semantics).

The array A is empty afterwards.

Definition at line 79 of file Array2D.h.

◆ ~Array2D()

template<class E >
ogdf::Array2D< E >::~Array2D ( )
inline

Destructor.

Definition at line 92 of file Array2D.h.

Member Function Documentation

◆ construct()

template<class E >
void ogdf::Array2D< E >::construct ( int  a,
int  b,
int  c,
int  d 
)
private

Constructs the array with index set [a, ..., b]*[c, ..., d].

Definition at line 212 of file Array2D.h.

◆ copy()

template<class E >
void ogdf::Array2D< E >::copy ( const Array2D< E > &  array2)
private

Copy array2.

Definition at line 283 of file Array2D.h.

◆ deconstruct()

template<class E >
void ogdf::Array2D< E >::deconstruct
private

Call destructor of all elements.

Definition at line 272 of file Array2D.h.

◆ det()

template<class E >
float ogdf::Array2D< E >::det

Returns the determinant of the matrix.

Computes the determinant via row expansion.

Note
use only for square matrices and floating point values

Definition at line 297 of file Array2D.h.

◆ fill()

template<class E >
void ogdf::Array2D< E >::fill ( const E &  x)
inline

Sets all elements to x.

Definition at line 182 of file Array2D.h.

◆ high1()

template<class E >
int ogdf::Array2D< E >::high1 ( ) const
inline

Returns the maximal array index in dimension 1.

Definition at line 98 of file Array2D.h.

◆ high2()

template<class E >
int ogdf::Array2D< E >::high2 ( ) const
inline

Returns the maximal array index in dimension 2.

Definition at line 104 of file Array2D.h.

◆ init() [1/3]

template<class E >
void ogdf::Array2D< E >::init ( )
inline

Reinitializes the array to an array with empty index set.

Definition at line 138 of file Array2D.h.

◆ init() [2/3]

template<class E >
void ogdf::Array2D< E >::init ( int  a,
int  b,
int  c,
int  d 
)
inline

Reinitializes the array to an array with index set [a, ..., b]*[c, ..., d].

Definition at line 141 of file Array2D.h.

◆ init() [3/3]

template<class E >
void ogdf::Array2D< E >::init ( int  a,
int  b,
int  c,
int  d,
const E &  x 
)
inline

Reinitializes the array to an array with index set [a, ..., b]*[c, ..., d] and initializes all entries with x.

Definition at line 148 of file Array2D.h.

◆ initialize() [1/2]

template<class E >
void ogdf::Array2D< E >::initialize
private

Initializes the array with default constructor of E.

Definition at line 238 of file Array2D.h.

◆ initialize() [2/2]

template<class E >
void ogdf::Array2D< E >::initialize ( const E &  x)
private

Initializes the array with x.

Definition at line 255 of file Array2D.h.

◆ low1()

template<class E >
int ogdf::Array2D< E >::low1 ( ) const
inline

Returns the minimal array index in dimension 1.

Definition at line 95 of file Array2D.h.

◆ low2()

template<class E >
int ogdf::Array2D< E >::low2 ( ) const
inline

Returns the minimal array index in dimension 2.

Definition at line 101 of file Array2D.h.

◆ operator()() [1/2]

template<class E >
E& ogdf::Array2D< E >::operator() ( int  i,
int  j 
)
inline

Returns a reference to the element with index (i,j).

Definition at line 129 of file Array2D.h.

◆ operator()() [2/2]

template<class E >
const E& ogdf::Array2D< E >::operator() ( int  i,
int  j 
) const
inline

Returns a reference to the element with index (i,j).

Definition at line 120 of file Array2D.h.

◆ operator=() [1/2]

template<class E >
Array2D<E>& ogdf::Array2D< E >::operator= ( Array2D< E > &&  A)
inline

Assignment operator (move semantics).

Array A is empty afterwards.

Definition at line 165 of file Array2D.h.

◆ operator=() [2/2]

template<class E >
Array2D<E>& ogdf::Array2D< E >::operator= ( const Array2D< E > &  array2)
inline

Assignment operator.

Definition at line 155 of file Array2D.h.

◆ size()

template<class E >
int ogdf::Array2D< E >::size ( ) const
inline

Returns the size (number of elements) of the array.

Definition at line 107 of file Array2D.h.

◆ size1()

template<class E >
int ogdf::Array2D< E >::size1 ( ) const
inline

Returns the length of the index interval (number of entries) in dimension 1.

Definition at line 110 of file Array2D.h.

◆ size2()

template<class E >
int ogdf::Array2D< E >::size2 ( ) const
inline

Returns the length of the index interval (number of entries) in dimension 2.

Definition at line 113 of file Array2D.h.

Member Data Documentation

◆ m_a

template<class E >
int ogdf::Array2D< E >::m_a
private

The lowest index in dimension 1.

Definition at line 195 of file Array2D.h.

◆ m_b

template<class E >
int ogdf::Array2D< E >::m_b
private

The highest index in dimension 1.

Definition at line 196 of file Array2D.h.

◆ m_c

template<class E >
int ogdf::Array2D< E >::m_c
private

The lowest index in dimension 2.

Definition at line 197 of file Array2D.h.

◆ m_d

template<class E >
int ogdf::Array2D< E >::m_d
private

The highest index in dimension 2.

Definition at line 198 of file Array2D.h.

◆ m_lenDim2

template<class E >
int ogdf::Array2D< E >::m_lenDim2
private

The number of elements in dimension 2.

Definition at line 191 of file Array2D.h.

◆ m_pStart

template<class E >
E* ogdf::Array2D< E >::m_pStart
private

The real start of the array (address of A[low1,low2]).

Definition at line 192 of file Array2D.h.

◆ m_pStop

template<class E >
E* ogdf::Array2D< E >::m_pStop
private

Successor of last element (address of A[high1,high2+1]).

Definition at line 193 of file Array2D.h.

◆ m_vpStart

template<class E >
E* ogdf::Array2D< E >::m_vpStart
private

The virtual start of the array (address of A[0,0]).

Definition at line 190 of file Array2D.h.


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