Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::FaceArray< T > Class Template Reference

Dynamic arrays indexed with faces of a combinatorial embedding. More...

#include <ogdf/basic/FaceArray.h>

+ Inheritance diagram for ogdf::FaceArray< T >:

Public Types

using const_iterator = internal::GraphArrayConstIterator< FaceArray< T > >
 The type for face array const iterators.
 
using iterator = internal::GraphArrayIterator< FaceArray< T > >
 The type for face array iterators.
 
using key_type = face
 The type for array keys.
 
using value_type = T
 The type for array entries.
 

Public Member Functions

 FaceArray ()
 Constructs an empty face array associated with no combinatorial embedding.
 
 FaceArray (const ConstCombinatorialEmbedding &E)
 Constructs a face array associated with E.
 
 FaceArray (const ConstCombinatorialEmbedding &E, const T &x)
 Constructs a face array associated with E.
 
 FaceArray (const FaceArray< T > &A)
 Constructs an face array that is a copy of A.
 
 FaceArray (FaceArray< T > &&A)
 Constructs a face array containing the elements of A (move semantics).
 
Access methods

These methods provide access to elements, size, and corresponding graph.

bool valid () const
 Returns true iff the array is associated with a combinatorial embedding.
 
const ConstCombinatorialEmbeddingembeddingOf () const
 Returns a pointer to the associated combinatorial embedding.
 
const T & operator[] (face f) const
 Returns a reference to the element with index f.
 
T & operator[] (face f)
 Returns a reference to the element with index f.
 
const T & operator() (face f) const
 Returns a reference to the element with index f.
 
T & operator() (face f)
 Returns a reference to the element with index f.
 
Iterators

These methods return bidirectional iterators to elements in the array.

iterator begin ()
 Returns an iterator to the first entry in the face array.
 
const_iterator begin () const
 Returns a const iterator to the first entry in the face array.
 
const_iterator cbegin () const
 Returns a const iterator to the first entry in the face array.
 
iterator end ()
 Returns an iterator to one-past-last entry in the face array.
 
const_iterator end () const
 Returns a const iterator to one-past-last entry in the face array.
 
const_iterator cend () const
 Returns a const iterator to one-past-last entry in the face array.
 
Initialization and assignment

These methods can be used to reinitialize the array, or to initialize all elements with a given value.

void init ()
 Reinitializes the array. Associates the array with no combinatorial embedding.
 
void init (const ConstCombinatorialEmbedding &E)
 Reinitializes the array. Associates the array with E.
 
void init (const ConstCombinatorialEmbedding &E, const T &x)
 Reinitializes the array. Associates the array with E.
 
void fill (const T &x)
 Sets all array elements to x.
 
FaceArray< T > & operator= (const FaceArray< T > &a)
 Assignment operator.
 
FaceArray< T > & operator= (FaceArray< T > &&a)
 Assignment operator (move semantics).
 

Static Public Member Functions

Helper functions

These methods are mainly intended for internal use.

static key_type findSuccKey (key_type key)
 
static key_type findPredKey (key_type key)
 

Private Member Functions

virtual void enlargeTable (int newTableSize)
 Virtual function called when table size has to be enlarged.
 
virtual void reinit (int initTableSize)
 Virtual function called when table has to be reinitialized.
 
- Private Member Functions inherited from ogdf::Array< T >
 Array ()
 Creates an array with empty index set.
 
 Array (Array< T, int > &&A)
 Creates an array containing the elements of A (move semantics).
 
 Array (const Array< T, int > &A)
 Creates an array that is a copy of A.
 
 Array (const ArrayBuffer< T, int > &A)
 Creates an array that is a copy of A. The array-size is set to be the number of elements (not the capacity) of the buffer.
 
 Array (int a, int b)
 Creates an array with index set [a..b].
 
 Array (int a, int b, const T &x)
 Creates an array with index set [a..b] and initializes each element with x.
 
 Array (int s)
 Creates an array with index set [0..s-1].
 
 Array (std::initializer_list< T > initList)
 Creates an array containing the elements in the initializer list initList.
 
 ~Array ()
 Destruction.
 
int low () const
 Returns the minimal array index.
 
int high () const
 Returns the maximal array index.
 
int size () const
 Returns the size (number of elements) of the array.
 
bool empty () const
 Returns true iff there are no elements in the array.
 
const_reference operator[] (int i) const
 Returns a reference to the element at position i.
 
reference operator[] (int i)
 Returns a reference to the element at position i.
 
iterator begin ()
 Returns an iterator to the first element.
 
const_iterator begin () const
 Returns a const iterator to the first element.
 
const_iterator cbegin () const
 Returns a const iterator to the first element.
 
iterator end ()
 Returns an iterator to one past the last element.
 
const_iterator end () const
 Returns a const iterator to one past the last element.
 
const_iterator cend () const
 Returns a const iterator to one past the last element.
 
reverse_iterator rbegin ()
 Returns an reverse iterator to the last element.
 
const_reverse_iterator rbegin () const
 Returns a const reverse iterator to the last element.
 
const_reverse_iterator crbegin () const
 Returns a const reverse iterator to the last element.
 
reverse_iterator rend ()
 Returns an reverse iterator to one before the first element.
 
const_reverse_iterator rend () const
 Returns a const reverse iterator to one before the first element.
 
const_reverse_iterator crend () const
 Returns a const reverse iterator to one before the first element.
 
void init ()
 Reinitializes the array to an array with empty index set.
 
void init (int s)
 Reinitializes the array to an array with index set [0..s-1].
 
void init (int a, int b)
 Reinitializes the array to an array with index set [a..b].
 
void init (int a, int b, const T &x)
 Reinitializes the array to an array with index set [a..b] and sets all entries to x.
 
void fill (const T &x)
 Sets all elements to x.
 
void fill (int i, int j, const T &x)
 Sets elements in the intervall [i..j] to x.
 
void grow (int add, const T &x)
 Enlarges the array by add elements and sets new elements to x.
 
void grow (int add)
 Enlarges the array by add elements.
 
void resize (int newSize, const T &x)
 Resizes (enlarges or shrinks) the array to hold newSize elements and sets new elements to x.
 
void resize (int newSize)
 Resizes (enlarges or shrinks) the array to hold newSize elements.
 
Array< T, int > & operator= (const Array< T, int > &A)
 Assignment operator.
 
Array< T, int > & operator= (Array< T, int > &&A)
 Assignment operator (move semantics).
 
bool operator== (const Array< T, int > &L) const
 Equality operator.
 
bool operator!= (const Array< T, int > &L) const
 Inequality operator.
 
void swap (int i, int j)
 Swaps the elements at position i and j.
 
void permute (int l, int r)
 Randomly permutes the subarray with index set [l..r].
 
void permute ()
 Randomly permutes the array.
 
void permute (int l, int r, RNG &rng)
 Randomly permutes the subarray with index set [l..r] using random number generator rng.
 
void permute (RNG &rng)
 Randomly permutes the array using random number generator rng.
 
int binarySearch (const T &e) const
 Performs a binary search for element e.
 
int binarySearch (int l, int r, const T &e) const
 Performs a binary search for element e within the array section [l, ..., r] .
 
int binarySearch (const T &e, const COMPARER &comp) const
 Performs a binary search for element e with comparer comp.
 
int binarySearch (int l, int r, const T &e, const COMPARER &comp) const
 Performs a binary search for element e within the array section [l, ..., r] with comparer comp.
 
int linearSearch (const T &e) const
 Performs a linear search for element e.
 
int linearSearch (const T &e, const COMPARER &comp) const
 Performs a linear search for element e with comparer comp.
 
void quicksort ()
 Sorts array using Quicksort.
 
void quicksort (int l, int r)
 Sorts subarray with index set [l, ..., r] using Quicksort.
 
void quicksort (const COMPARER &comp)
 Sorts array using Quicksort and a user-defined comparer comp.
 
void quicksort (int l, int r, const COMPARER &comp)
 Sorts the subarray with index set [l, ..., r] using Quicksort and a user-defined comparer comp.
 
void leftShift (ArrayBuffer< int, int > &ind)
 Removes the components listed in ind by shifting the remaining components to the left.
 
void leftShift (ArrayBuffer< int, int > &ind, const T &val)
 Removes the components listed in ind by shifting the remaining components to the left.
 

Private Attributes

m_x
 The default value for array elements.
 

Additional Inherited Members

- Protected Member Functions inherited from ogdf::FaceArrayBase
 FaceArrayBase ()
 Initializes a face array not associated with a combinatorial embedding.
 
 FaceArrayBase (const ConstCombinatorialEmbedding *pE)
 Initializes a face array associated with pE.
 
 FaceArrayBase (FaceArrayBase &base)
 Moves face array base to this face array.
 
virtual ~FaceArrayBase ()
 
void moveRegister (FaceArrayBase &base)
 Moves array registration from base to this array.
 
void reregister (const ConstCombinatorialEmbedding *pE)
 Associates the array with a new combinatorial embedding.
 
- Protected Attributes inherited from ogdf::FaceArrayBase
const ConstCombinatorialEmbeddingm_pEmbedding
 The associated combinatorial embedding.
 
- Private Types inherited from ogdf::Array< T >
using const_iterator = ArrayConstIterator< T >
 Provides a random-access iterator that can read a const element in an array.
 
using const_reference = const T &
 Provides a reference to a const element stored in an array for reading and performing const operations.
 
using const_reverse_iterator = ArrayConstReverseIterator< T >
 Provides a reverse random-access iterator that can read a const element in an array.
 
using iterator = ArrayIterator< T >
 Provides a random-access iterator that can read or modify any element in an array.
 
using reference = T &
 Provides a reference to an element stored in an array.
 
using reverse_iterator = ArrayReverseIterator< T >
 Provides a reverse random-access iterator that can read or modify any element in an array.
 
using value_type = T
 Represents the data type stored in an array element.
 
- Static Private Attributes inherited from ogdf::Array< T >
static const int maxSizeInsertionSort
 Threshold used by quicksort() such that insertion sort is called for instances smaller than maxSizeInsertionSort.
 

Detailed Description

template<class T>
class ogdf::FaceArray< T >

Dynamic arrays indexed with faces of a combinatorial embedding.

Face arrays represent a mapping from faces to data of type T. They adjust their table size automatically when the number of faces in the corresponding combinatorial embedding increases.

Warning
Undefined behavior can occur when the array is used in the left-hand side of an assignment and the observed graph is changed in the right-hand side. To resolve the issue, use:
auto tmp = RHS; LHS = std::move(tmp);
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
Template Parameters
Tis the element type.

Definition at line 126 of file FaceArray.h.

Member Typedef Documentation

◆ const_iterator

template<class T >
using ogdf::FaceArray< T >::const_iterator = internal::GraphArrayConstIterator<FaceArray<T> >

The type for face array const iterators.

Definition at line 138 of file FaceArray.h.

◆ iterator

The type for face array iterators.

Definition at line 136 of file FaceArray.h.

◆ key_type

template<class T >
using ogdf::FaceArray< T >::key_type = face

The type for array keys.

Definition at line 131 of file FaceArray.h.

◆ value_type

template<class T >
using ogdf::FaceArray< T >::value_type = T

The type for array entries.

Definition at line 133 of file FaceArray.h.

Constructor & Destructor Documentation

◆ FaceArray() [1/5]

template<class T >
ogdf::FaceArray< T >::FaceArray ( )
inline

Constructs an empty face array associated with no combinatorial embedding.

Definition at line 141 of file FaceArray.h.

◆ FaceArray() [2/5]

template<class T >
ogdf::FaceArray< T >::FaceArray ( const ConstCombinatorialEmbedding E)
inline

Constructs a face array associated with E.

Definition at line 144 of file FaceArray.h.

◆ FaceArray() [3/5]

template<class T >
ogdf::FaceArray< T >::FaceArray ( const ConstCombinatorialEmbedding E,
const T &  x 
)
inline

Constructs a face array associated with E.

Parameters
Eis the associated combinatorial embedding.
xis the default value for all array elements.

Definition at line 152 of file FaceArray.h.

◆ FaceArray() [4/5]

template<class T >
ogdf::FaceArray< T >::FaceArray ( const FaceArray< T > &  A)
inline

Constructs an face array that is a copy of A.

Associates the array with the same combinatorial embedding as A and copies all elements.

Definition at line 160 of file FaceArray.h.

◆ FaceArray() [5/5]

template<class T >
ogdf::FaceArray< T >::FaceArray ( FaceArray< T > &&  A)
inline

Constructs a face array containing the elements of A (move semantics).

Face array A is empty afterwards and not associated with any combinatorial embedding.

Definition at line 166 of file FaceArray.h.

Member Function Documentation

◆ begin() [1/2]

template<class T >
iterator ogdf::FaceArray< T >::begin ( )
inline

Returns an iterator to the first entry in the face array.

If the face array is empty, a null pointer iterator is returned.

Definition at line 219 of file FaceArray.h.

◆ begin() [2/2]

template<class T >
const_iterator ogdf::FaceArray< T >::begin ( ) const
inline

Returns a const iterator to the first entry in the face array.

If the face array is empty, a null pointer iterator is returned.

Definition at line 225 of file FaceArray.h.

◆ cbegin()

template<class T >
const_iterator ogdf::FaceArray< T >::cbegin ( ) const
inline

Returns a const iterator to the first entry in the face array.

If the face array is empty, a null pointer iterator is returned.

Definition at line 231 of file FaceArray.h.

◆ cend()

template<class T >
const_iterator ogdf::FaceArray< T >::cend ( ) const
inline

Returns a const iterator to one-past-last entry in the face array.

This is always a null pointer iterator.

Definition at line 249 of file FaceArray.h.

◆ embeddingOf()

template<class T >
const ConstCombinatorialEmbedding * ogdf::FaceArray< T >::embeddingOf ( ) const
inline

Returns a pointer to the associated combinatorial embedding.

Definition at line 178 of file FaceArray.h.

◆ end() [1/2]

template<class T >
iterator ogdf::FaceArray< T >::end ( )
inline

Returns an iterator to one-past-last entry in the face array.

This is always a null pointer iterator.

Definition at line 237 of file FaceArray.h.

◆ end() [2/2]

template<class T >
const_iterator ogdf::FaceArray< T >::end ( ) const
inline

Returns a const iterator to one-past-last entry in the face array.

This is always a null pointer iterator.

Definition at line 243 of file FaceArray.h.

◆ enlargeTable()

template<class T >
virtual void ogdf::FaceArray< T >::enlargeTable ( int  newTableSize)
inlineprivatevirtual

Virtual function called when table size has to be enlarged.

Implements ogdf::FaceArrayBase.

Definition at line 321 of file FaceArray.h.

◆ fill()

template<class T >
void ogdf::FaceArray< T >::fill ( const T &  x)
inline

Sets all array elements to x.

Definition at line 281 of file FaceArray.h.

◆ findPredKey()

template<class T >
static key_type ogdf::FaceArray< T >::findPredKey ( key_type  key)
inlinestatic

Definition at line 316 of file FaceArray.h.

◆ findSuccKey()

template<class T >
static key_type ogdf::FaceArray< T >::findSuccKey ( key_type  key)
inlinestatic

Definition at line 314 of file FaceArray.h.

◆ init() [1/3]

template<class T >
void ogdf::FaceArray< T >::init ( )
inline

Reinitializes the array. Associates the array with no combinatorial embedding.

Definition at line 259 of file FaceArray.h.

◆ init() [2/3]

template<class T >
void ogdf::FaceArray< T >::init ( const ConstCombinatorialEmbedding E)
inline

Reinitializes the array. Associates the array with E.

Definition at line 265 of file FaceArray.h.

◆ init() [3/3]

template<class T >
void ogdf::FaceArray< T >::init ( const ConstCombinatorialEmbedding E,
const T &  x 
)
inline

Reinitializes the array. Associates the array with E.

Parameters
Eis the associated combinatorial embedding.
xis the default value.

Definition at line 275 of file FaceArray.h.

◆ operator()() [1/2]

template<class T >
T & ogdf::FaceArray< T >::operator() ( face  f)
inline

Returns a reference to the element with index f.

Definition at line 202 of file FaceArray.h.

◆ operator()() [2/2]

template<class T >
const T & ogdf::FaceArray< T >::operator() ( face  f) const
inline

Returns a reference to the element with index f.

Definition at line 195 of file FaceArray.h.

◆ operator=() [1/2]

template<class T >
FaceArray< T > & ogdf::FaceArray< T >::operator= ( const FaceArray< T > &  a)
inline

Assignment operator.

Definition at line 289 of file FaceArray.h.

◆ operator=() [2/2]

template<class T >
FaceArray< T > & ogdf::FaceArray< T >::operator= ( FaceArray< T > &&  a)
inline

Assignment operator (move semantics).

Face array a is empty afterwards and not associated with any combinatorial embedding.

Definition at line 300 of file FaceArray.h.

◆ operator[]() [1/2]

template<class T >
T & ogdf::FaceArray< T >::operator[] ( face  f)
inline

Returns a reference to the element with index f.

Definition at line 188 of file FaceArray.h.

◆ operator[]() [2/2]

template<class T >
const T & ogdf::FaceArray< T >::operator[] ( face  f) const
inline

Returns a reference to the element with index f.

Definition at line 181 of file FaceArray.h.

◆ reinit()

template<class T >
virtual void ogdf::FaceArray< T >::reinit ( int  initTableSize)
inlineprivatevirtual

Virtual function called when table has to be reinitialized.

Implements ogdf::FaceArrayBase.

Definition at line 323 of file FaceArray.h.

◆ valid()

template<class T >
bool ogdf::FaceArray< T >::valid ( ) const
inline

Returns true iff the array is associated with a combinatorial embedding.

Definition at line 175 of file FaceArray.h.

Member Data Documentation

◆ m_x

template<class T >
T ogdf::FaceArray< T >::m_x
private

The default value for array elements.

Definition at line 127 of file FaceArray.h.


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