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. | |
| using | iterator = internal::GraphArrayIterator< ClusterArray< T > > |
| The type for cluster array iterators. | |
| using | key_type = cluster |
| The type for array keys. | |
| using | value_type = T |
| The type for array entries. | |
Public Member Functions | |
| ClusterArray () | |
| Constructs an empty cluster array associated with no graph. | |
| ClusterArray (ClusterArray< T > &&A) | |
Constructs a cluster array containing the elements of A (move semantics). | |
| ClusterArray (const ClusterArray< T > &A) | |
Constructs a cluster array that is a copy of A. | |
| ClusterArray (const ClusterGraph &C) | |
Constructs a cluster array associated with C. | |
| ClusterArray (const ClusterGraph &C, const T &x) | |
Constructs a cluster array associated with C. | |
| ClusterArray (const ClusterGraph &C, const T &x, int size) | |
Constructs a cluster array associated with C and a given size (for static use). | |
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. | |
| const ClusterGraph * | graphOf () const |
| Returns a pointer to the associated cluster graph. | |
| const T & | operator[] (cluster c) const |
Returns a reference to the element with index c. | |
| T & | operator[] (cluster c) |
Returns a reference to the element with index c. | |
| const T & | operator() (cluster c) const |
Returns a reference to the element with index c. | |
| T & | operator() (cluster c) |
Returns a reference to the element with index c. | |
| const T & | operator[] (int index) const |
Returns a reference to the element with index index. | |
| T & | operator[] (int index) |
Returns a reference to the element with index index. | |
Iterators | |
These methods return bidirectional iterators to elements in the array. | |
| iterator | begin () |
| Returns an iterator to the first entry in the cluster array. | |
| const_iterator | begin () const |
| Returns a const iterator to the first entry in the cluster array. | |
| const_iterator | cbegin () const |
| Returns a const iterator to the first entry in the cluster array. | |
| iterator | end () |
| Returns an iterator to one-past-last entry in the cluster array. | |
| const_iterator | end () const |
| Returns a const iterator to one-past-last entry in the cluster array. | |
| const_iterator | cend () const |
| Returns a const iterator to one-past-last entry in the cluster 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 cluster graph. | |
| void | init (const ClusterGraph &C) |
Reinitializes the array. Associates the array with C. | |
| void | init (const ClusterGraph &C, const T &x) |
Reinitializes the array. Associates the array with C. | |
| void | fill (const T &x) |
Sets all array elements to x. | |
| ClusterArray< T > & | operator= (const ClusterArray< T > &a) |
| Assignment operator. | |
| ClusterArray< T > & | operator= (ClusterArray< 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 | disconnect () |
| Virtual function called when array is disconnected from the cluster graph. | |
| 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 | |
| T | m_x |
| The default value for array elements. | |
Additional Inherited Members | |
Protected Member Functions inherited from ogdf::ClusterArrayBase | |
| ClusterArrayBase () | |
| Initializes a cluster array not associated with a cluster graph. | |
| ClusterArrayBase (ClusterArrayBase &base) | |
Moves cluster array base to this cluster array. | |
| ClusterArrayBase (const ClusterGraph *pC) | |
Initializes a cluster array associated with pC. | |
| virtual | ~ClusterArrayBase () |
| void | moveRegister (ClusterArrayBase &base) |
Moves array registration from base to this array. | |
| void | reregister (const ClusterGraph *pC) |
| Associates the array with a new cluster graph. | |
Protected Attributes inherited from ogdf::ClusterArrayBase | |
| const ClusterGraph * | m_pClusterGraph |
| The associated cluster graph. | |
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. | |
Dynamic arrays indexed with clusters.
Cluster arrays adjust their table size automatically when the cluster graph grows.
Definition at line 124 of file ClusterArray.h.
| using ogdf::ClusterArray< T >::const_iterator = internal::GraphArrayConstIterator<ClusterArray<T> > |
The type for cluster array const iterators.
Definition at line 136 of file ClusterArray.h.
| using ogdf::ClusterArray< T >::iterator = internal::GraphArrayIterator<ClusterArray<T> > |
The type for cluster array iterators.
Definition at line 134 of file ClusterArray.h.
| using ogdf::ClusterArray< T >::key_type = cluster |
The type for array keys.
Definition at line 129 of file ClusterArray.h.
| using ogdf::ClusterArray< T >::value_type = T |
The type for array entries.
Definition at line 131 of file ClusterArray.h.
|
inline |
Constructs an empty cluster array associated with no graph.
Definition at line 139 of file ClusterArray.h.
|
inline |
Constructs a cluster array associated with C.
Definition at line 142 of file ClusterArray.h.
|
inline |
Constructs a cluster array associated with C.
| C | is the associated cluster graph. |
| x | is the default value for all array elements. |
Definition at line 150 of file ClusterArray.h.
|
inline |
Constructs a cluster array associated with C and a given size (for static use).
| C | is the associated cluster graph. |
| x | is the default value for all array elements. |
| size | is the size of the array. |
Definition at line 160 of file ClusterArray.h.
|
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 167 of file ClusterArray.h.
|
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 174 of file ClusterArray.h.
|
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 239 of file ClusterArray.h.
|
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.
|
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 251 of file ClusterArray.h.
|
inline |
Returns a const iterator to one-past-last entry in the cluster array.
This is always a null pointer iterator.
Definition at line 269 of file ClusterArray.h.
|
inlineprivatevirtual |
Virtual function called when array is disconnected from the cluster graph.
Implements ogdf::ClusterArrayBase.
Definition at line 345 of file ClusterArray.h.
|
inline |
Returns an 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.
|
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.
|
inlineprivatevirtual |
Virtual function called when table size has to be enlarged.
Implements ogdf::ClusterArrayBase.
Definition at line 341 of file ClusterArray.h.
|
inline |
Sets all array elements to x.
Definition at line 301 of file ClusterArray.h.
|
inlinestatic |
Definition at line 336 of file ClusterArray.h.
|
inlinestatic |
Definition at line 334 of file ClusterArray.h.
|
inline |
Returns a pointer to the associated cluster graph.
Definition at line 186 of file ClusterArray.h.
|
inline |
Reinitializes the array. Associates the array with no cluster graph.
Definition at line 279 of file ClusterArray.h.
|
inline |
Reinitializes the array. Associates the array with C.
Definition at line 285 of file ClusterArray.h.
|
inline |
Reinitializes the array. Associates the array with C.
| C | is the associated cluster graph. |
| x | is the default value. |
Definition at line 295 of file ClusterArray.h.
|
inline |
Returns a reference to the element with index c.
Definition at line 210 of file ClusterArray.h.
|
inline |
Returns a reference to the element with index c.
Definition at line 203 of file ClusterArray.h.
|
inline |
Assignment operator (move semantics).
Cluster array a is empty afterwards and not associated with any cluster graph.
Definition at line 320 of file ClusterArray.h.
|
inline |
Assignment operator.
Definition at line 309 of file ClusterArray.h.
|
inline |
Returns a reference to the element with index c.
Definition at line 196 of file ClusterArray.h.
|
inline |
Returns a reference to the element with index c.
Definition at line 189 of file ClusterArray.h.
|
inline |
Returns a reference to the element with index index.
index is a valid index for a cluster in the associated cluster graph! Definition at line 226 of file ClusterArray.h.
|
inline |
Returns a reference to the element with index index.
index is a valid index for a cluster in the associated cluster graph! Definition at line 220 of file ClusterArray.h.
|
inlineprivatevirtual |
Virtual function called when table has to be reinitialized.
Implements ogdf::ClusterArrayBase.
Definition at line 343 of file ClusterArray.h.
|
inline |
Returns true iff the array is associated with a graph.
Definition at line 183 of file ClusterArray.h.
|
private |
The default value for array elements.
Definition at line 125 of file ClusterArray.h.