Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

ogdf::ClusterArray< T > Class Template Reference

Dynamic arrays indexed with clusters. More...

#include <ogdf/cluster/ClusterArray.h>

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

Public Types

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

Public Member Functions

 ClusterArray ()
 Constructs an empty cluster array associated with no graph. More...
 
 ClusterArray (ClusterArray< T > &&A)
 Constructs a cluster array containing the elements of A (move semantics). More...
 
 ClusterArray (const ClusterArray< T > &A)
 Constructs a cluster array that is a copy of A. More...
 
 ClusterArray (const ClusterGraph &C)
 Constructs a cluster array associated with C. More...
 
 ClusterArray (const ClusterGraph &C, const T &x)
 Constructs a cluster array associated with C. More...
 
 ClusterArray (const ClusterGraph &C, const T &x, int size)
 Constructs a cluster array associated with C and a given size (for static use). More...
 
Access methods

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

bool valid () const
 Returns true iff the array is associated with a graph. More...
 
const ClusterGraphgraphOf () const
 Returns a pointer to the associated cluster graph. More...
 
const T & operator[] (cluster c) const
 Returns a reference to the element with index c. More...
 
T & operator[] (cluster c)
 Returns a reference to the element with index c. More...
 
const T & operator() (cluster c) const
 Returns a reference to the element with index c. More...
 
T & operator() (cluster c)
 Returns a reference to the element with index c. More...
 
const T & operator[] (int index) const
 Returns a reference to the element with index index. More...
 
T & operator[] (int index)
 Returns a reference to the element with index index. More...
 
Iterators

These methods return bidirectional iterators to elements in the array.

iterator begin ()
 Returns an iterator to the first entry in the cluster array. More...
 
const_iterator begin () const
 Returns a const iterator to the first entry in the cluster array. More...
 
const_iterator cbegin () const
 Returns a const iterator to the first entry in the cluster array. More...
 
iterator end ()
 Returns an iterator to one-past-last entry in the cluster array. More...
 
const_iterator end () const
 Returns a const iterator to one-past-last entry in the cluster array. More...
 
const_iterator cend () const
 Returns a const iterator to one-past-last entry in the cluster array. More...
 
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 cluster graph. More...
 
void init (const ClusterGraph &C)
 Reinitializes the array. Associates the array with C. More...
 
void init (const ClusterGraph &C, const T &x)
 Reinitializes the array. Associates the array with C. More...
 
void fill (const T &x)
 Sets all array elements to x. More...
 
ClusterArray< T > & operator= (const ClusterArray< T > &a)
 Assignment operator. More...
 
ClusterArray< T > & operator= (ClusterArray< T > &&a)
 Assignment operator (move semantics). More...
 

Private Attributes

m_x
 The default value for array elements. More...
 

Helper functions

These methods are mainly intended for internal use.

static key_type findSuccKey (key_type key)
 
static key_type findPredKey (key_type key)
 
virtual void enlargeTable (int newTableSize)
 Virtual function called when table size has to be enlarged. More...
 
virtual void reinit (int initTableSize)
 Virtual function called when table has to be reinitialized. More...
 
virtual void disconnect ()
 Virtual function called when array is disconnected from the cluster graph. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ogdf::ClusterArrayBase
 ClusterArrayBase ()
 Initializes a cluster array not associated with a cluster graph. More...
 
 ClusterArrayBase (ClusterArrayBase &base)
 Moves cluster array base to this cluster array. More...
 
 ClusterArrayBase (const ClusterGraph *pC)
 Initializes a cluster array associated with pC. More...
 
virtual ~ClusterArrayBase ()
 
void moveRegister (ClusterArrayBase &base)
 Moves array registration from base to this array. More...
 
void reregister (const ClusterGraph *pC)
 Associates the array with a new cluster graph. More...
 
- Protected Attributes inherited from ogdf::ClusterArrayBase
const ClusterGraphm_pClusterGraph
 The associated cluster graph. More...
 
- 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. More...
 
using const_reference = const T &
 Provides a reference to a const element stored in an array for reading and performing const operations. More...
 
using const_reverse_iterator = ArrayConstReverseIterator< T >
 Provides a reverse random-access iterator that can read a const element in an array. More...
 
using iterator = ArrayIterator< T >
 Provides a random-access iterator that can read or modify any element in an array. More...
 
using reference = T &
 Provides a reference to an element stored in an array. More...
 
using reverse_iterator = ArrayReverseIterator< T >
 Provides a reverse random-access iterator that can read or modify any element in an array. More...
 
using value_type = T
 Represents the data type stored in an array element. More...
 
- Private Member Functions inherited from ogdf::Array< T >
 Array ()
 Creates an array with empty index set. More...
 
 Array (Array< T, int > &&A)
 Creates an array containing the elements of A (move semantics). More...
 
 Array (const Array< T, int > &A)
 Creates an array that is a copy of A. More...
 
 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. More...
 
 Array (int a, int b)
 Creates an array with index set [a..b]. More...
 
 Array (int a, int b, const T &x)
 Creates an array with index set [a..b] and initializes each element with x. More...
 
 Array (int s)
 Creates an array with index set [0..s-1]. More...
 
 Array (std::initializer_list< T > initList)
 Creates an array containing the elements in the initializer list initList. More...
 
 ~Array ()
 Destruction. More...
 
int low () const
 Returns the minimal array index. More...
 
int high () const
 Returns the maximal array index. More...
 
int size () const
 Returns the size (number of elements) of the array. More...
 
bool empty () const
 Returns true iff there are no elements in the array. More...
 
const_reference operator[] (int i) const
 Returns a reference to the element at position i. More...
 
reference operator[] (int i)
 Returns a reference to the element at position i. More...
 
iterator begin ()
 Returns an iterator to the first element. More...
 
const_iterator begin () const
 Returns a const iterator to the first element. More...
 
const_iterator cbegin () const
 Returns a const iterator to the first element. More...
 
iterator end ()
 Returns an iterator to one past the last element. More...
 
const_iterator end () const
 Returns a const iterator to one past the last element. More...
 
const_iterator cend () const
 Returns a const iterator to one past the last element. More...
 
reverse_iterator rbegin ()
 Returns an reverse iterator to the last element. More...
 
const_reverse_iterator rbegin () const
 Returns a const reverse iterator to the last element. More...
 
const_reverse_iterator crbegin () const
 Returns a const reverse iterator to the last element. More...
 
reverse_iterator rend ()
 Returns an reverse iterator to one before the first element. More...
 
const_reverse_iterator rend () const
 Returns a const reverse iterator to one before the first element. More...
 
const_reverse_iterator crend () const
 Returns a const reverse iterator to one before the first element. More...
 
void init ()
 Reinitializes the array to an array with empty index set. More...
 
void init (int s)
 Reinitializes the array to an array with index set [0..s-1]. More...
 
void init (int a, int b)
 Reinitializes the array to an array with index set [a..b]. More...
 
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. More...
 
void fill (const T &x)
 Sets all elements to x. More...
 
void fill (int i, int j, const T &x)
 Sets elements in the intervall [i..j] to x. More...
 
void grow (int add, const T &x)
 Enlarges the array by add elements and sets new elements to x. More...
 
void grow (int add)
 Enlarges the array by add elements. More...
 
void resize (int newSize, const T &x)
 Resizes (enlarges or shrinks) the array to hold newSize elements and sets new elements to x. More...
 
void resize (int newSize)
 Resizes (enlarges or shrinks) the array to hold newSize elements. More...
 
Array< T, int > & operator= (const Array< T, int > &A)
 Assignment operator. More...
 
Array< T, int > & operator= (Array< T, int > &&A)
 Assignment operator (move semantics). More...
 
bool operator== (const Array< T, int > &L) const
 Equality operator. More...
 
bool operator!= (const Array< T, int > &L) const
 Inequality operator. More...
 
void swap (int i, int j)
 Swaps the elements at position i and j. More...
 
void permute (int l, int r)
 Randomly permutes the subarray with index set [l..r]. More...
 
void permute ()
 Randomly permutes the array. More...
 
void permute (int l, int r, RNG &rng)
 Randomly permutes the subarray with index set [l..r] using random number generator rng. More...
 
void permute (RNG &rng)
 Randomly permutes the array using random number generator rng. More...
 
int binarySearch (const T &e) const
 Performs a binary search for element e. More...
 
int binarySearch (int l, int r, const T &e) const
 Performs a binary search for element e within the array section [l, ..., r] . More...
 
int binarySearch (const T &e, const COMPARER &comp) const
 Performs a binary search for element e with comparer comp. More...
 
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. More...
 
int linearSearch (const T &e) const
 Performs a linear search for element e. More...
 
int linearSearch (const T &e, const COMPARER &comp) const
 Performs a linear search for element e with comparer comp. More...
 
void quicksort ()
 Sorts array using Quicksort. More...
 
void quicksort (int l, int r)
 Sorts subarray with index set [l, ..., r] using Quicksort. More...
 
void quicksort (const COMPARER &comp)
 Sorts array using Quicksort and a user-defined comparer comp. More...
 
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. More...
 
void leftShift (ArrayBuffer< int, int > &ind)
 Removes the components listed in ind by shifting the remaining components to the left. More...
 
void leftShift (ArrayBuffer< int, int > &ind, const T &val)
 Removes the components listed in ind by shifting the remaining components to the left. More...
 
- 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. More...
 

Detailed Description

template<class T>
class ogdf::ClusterArray< T >

Dynamic arrays indexed with clusters.

Cluster arrays adjust their table size automatically when the cluster graph grows.

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);

Definition at line 110 of file ClusterArray.h.

Member Typedef Documentation

◆ const_iterator

The type for cluster array const iterators.

Definition at line 122 of file ClusterArray.h.

◆ iterator

The type for cluster array iterators.

Definition at line 120 of file ClusterArray.h.

◆ key_type

template<class T >
using ogdf::ClusterArray< T >::key_type = cluster

The type for array keys.

Definition at line 115 of file ClusterArray.h.

◆ value_type

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

The type for array entries.

Definition at line 117 of file ClusterArray.h.

Constructor & Destructor Documentation

◆ ClusterArray() [1/6]

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

Constructs an empty cluster array associated with no graph.

Definition at line 126 of file ClusterArray.h.

◆ ClusterArray() [2/6]

template<class T >
ogdf::ClusterArray< T >::ClusterArray ( const ClusterGraph C)
inline

Constructs a cluster array associated with C.

Definition at line 129 of file ClusterArray.h.

◆ ClusterArray() [3/6]

template<class T >
ogdf::ClusterArray< T >::ClusterArray ( const ClusterGraph C,
const T &  x 
)
inline

Constructs a cluster array associated with C.

Parameters
Cis the associated cluster graph.
xis the default value for all array elements.

Definition at line 138 of file ClusterArray.h.

◆ ClusterArray() [4/6]

template<class T >
ogdf::ClusterArray< T >::ClusterArray ( const ClusterGraph C,
const T &  x,
int  size 
)
inline

Constructs a cluster array associated with C and a given size (for static use).

Parameters
Cis the associated cluster graph.
xis the default value for all array elements.
sizeis the size of the array.

Definition at line 149 of file ClusterArray.h.

◆ ClusterArray() [5/6]

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

Constructs a cluster array that is a copy of A.

Associates the array with the same cluster graph as A and copies all elements.

Definition at line 157 of file ClusterArray.h.

◆ ClusterArray() [6/6]

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

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

Cluster array A is empty afterwards and not associated with any cluster graph.

Definition at line 165 of file ClusterArray.h.

Member Function Documentation

◆ begin() [1/2]

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

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

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

Definition at line 233 of file ClusterArray.h.

◆ begin() [2/2]

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

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

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

Definition at line 239 of file ClusterArray.h.

◆ cbegin()

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

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

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

Definition at line 245 of file ClusterArray.h.

◆ cend()

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

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

This is always a null pointer iterator.

Definition at line 263 of file ClusterArray.h.

◆ disconnect()

template<class T >
virtual void ogdf::ClusterArray< T >::disconnect ( )
inlineprivatevirtual

Virtual function called when array is disconnected from the cluster graph.

Implements ogdf::ClusterArrayBase.

Definition at line 339 of file ClusterArray.h.

◆ end() [1/2]

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

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

This is always a null pointer iterator.

Definition at line 251 of file ClusterArray.h.

◆ end() [2/2]

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

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

This is always a null pointer iterator.

Definition at line 257 of file ClusterArray.h.

◆ enlargeTable()

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

Virtual function called when table size has to be enlarged.

Implements ogdf::ClusterArrayBase.

Definition at line 331 of file ClusterArray.h.

◆ fill()

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

Sets all array elements to x.

Definition at line 292 of file ClusterArray.h.

◆ findPredKey()

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

Definition at line 326 of file ClusterArray.h.

◆ findSuccKey()

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

Definition at line 325 of file ClusterArray.h.

◆ graphOf()

template<class T >
const ClusterGraph* ogdf::ClusterArray< T >::graphOf ( ) const
inline

Returns a pointer to the associated cluster graph.

Definition at line 178 of file ClusterArray.h.

◆ init() [1/3]

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

Reinitializes the array. Associates the array with no cluster graph.

Definition at line 273 of file ClusterArray.h.

◆ init() [2/3]

template<class T >
void ogdf::ClusterArray< T >::init ( const ClusterGraph C)
inline

Reinitializes the array. Associates the array with C.

Definition at line 278 of file ClusterArray.h.

◆ init() [3/3]

template<class T >
void ogdf::ClusterArray< T >::init ( const ClusterGraph C,
const T &  x 
)
inline

Reinitializes the array. Associates the array with C.

Parameters
Cis the associated cluster graph.
xis the default value.

Definition at line 287 of file ClusterArray.h.

◆ operator()() [1/2]

template<class T >
T& ogdf::ClusterArray< T >::operator() ( cluster  c)
inline

Returns a reference to the element with index c.

Definition at line 204 of file ClusterArray.h.

◆ operator()() [2/2]

template<class T >
const T& ogdf::ClusterArray< T >::operator() ( cluster  c) const
inline

Returns a reference to the element with index c.

Definition at line 197 of file ClusterArray.h.

◆ operator=() [1/2]

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

Assignment operator (move semantics).

Cluster array a is empty afterwards and not associated with any cluster graph.

Definition at line 310 of file ClusterArray.h.

◆ operator=() [2/2]

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

Assignment operator.

Definition at line 299 of file ClusterArray.h.

◆ operator[]() [1/4]

template<class T >
T& ogdf::ClusterArray< T >::operator[] ( cluster  c)
inline

Returns a reference to the element with index c.

Definition at line 190 of file ClusterArray.h.

◆ operator[]() [2/4]

template<class T >
const T& ogdf::ClusterArray< T >::operator[] ( cluster  c) const
inline

Returns a reference to the element with index c.

Definition at line 183 of file ClusterArray.h.

◆ operator[]() [3/4]

template<class T >
T& ogdf::ClusterArray< T >::operator[] ( int  index)
inline

Returns a reference to the element with index index.

Attention
Make sure that index is a valid index for a cluster in the associated cluster graph!
Deprecated:
"Cluster arrays should be indexed by a cluster, not an integer index."

Definition at line 219 of file ClusterArray.h.

◆ operator[]() [4/4]

template<class T >
const T& ogdf::ClusterArray< T >::operator[] ( int  index) const
inline

Returns a reference to the element with index index.

Attention
Make sure that index is a valid index for a cluster in the associated cluster graph!
Deprecated:
"Cluster arrays should be indexed by a cluster, not an integer index."

Definition at line 213 of file ClusterArray.h.

◆ reinit()

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

Virtual function called when table has to be reinitialized.

Implements ogdf::ClusterArrayBase.

Definition at line 335 of file ClusterArray.h.

◆ valid()

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

Returns true iff the array is associated with a graph.

Definition at line 175 of file ClusterArray.h.

Member Data Documentation

◆ m_x

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

The default value for array elements.

Definition at line 111 of file ClusterArray.h.


The documentation for this class was generated from the following file:
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:243