Dynamic arrays indexed with nodes. More...
#include <ogdf/basic/Graph_d.h>
Inheritance diagram for ogdf::NodeArray< T >:Public Types | |
| using | const_iterator = internal::GraphArrayConstIterator< NodeArray< T > > |
| The type for node array const iterators. More... | |
| using | iterator = internal::GraphArrayIterator< NodeArray< T > > |
| The type for node array iterators. More... | |
| using | key_type = node |
| The type for array keys. More... | |
| using | value_type = T |
| The type for array entries. More... | |
Public Member Functions | |
| NodeArray () | |
| Constructs an empty node array associated with no graph. More... | |
| NodeArray (const Graph &G) | |
Constructs a node array associated with G. More... | |
| NodeArray (const Graph &G, const T &x) | |
Constructs a node array associated with G. More... | |
| NodeArray (const NodeArray< T > &A) | |
Constructs a node array that is a copy of A. More... | |
| NodeArray (NodeArray< T > &&A) | |
Constructs a node array containing the elements of A (move semantics). More... | |
Access methods | |
These methods provide access to elements and the corresponding graph. | |
| bool | valid () const |
| Returns true iff the array is associated with a graph. More... | |
| const Graph * | graphOf () const |
| Returns a pointer to the associated graph. More... | |
| const T & | operator[] (node v) const |
Returns a reference to the element with index v. More... | |
| T & | operator[] (node v) |
Returns a reference to the element with index v. More... | |
| const T & | operator() (node v) const |
Returns a reference to the element with index v. More... | |
| T & | operator() (node v) |
Returns a reference to the element with index v. 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 node array. More... | |
| const_iterator | begin () const |
| Returns a const iterator to the first entry in the node array. More... | |
| const_iterator | cbegin () const |
| Returns a const iterator to the first entry in the node array. More... | |
| iterator | end () |
| Returns an iterator to one-past-last entry in the node array. More... | |
| const_iterator | end () const |
| Returns a const iterator to one-past-last entry in the node array. More... | |
| const_iterator | cend () const |
| Returns a const iterator to one-past-last entry in the node array. More... | |
| iterator | rbegin () |
| Returns an iterator to the last entry in the node array. More... | |
| const_iterator | rbegin () const |
| Returns a const iterator to the last entry in the node array. More... | |
| const_iterator | crbegin () const |
| Returns a const iterator to the last entry in the node array. More... | |
| iterator | rend () |
| Returns an iterator to one-before-first entry in the node array. More... | |
| const_iterator | rend () const |
| Returns a const iterator to one-before-first entry in the node array. More... | |
| const_iterator | crend () const |
| Returns a const iterator to one-before-first entry in the node 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 graph. More... | |
| void | init (const Graph &G) |
Reinitializes the array. Associates the array with G. More... | |
| void | init (const Graph &G, const T &x) |
Reinitializes the array. Associates the array with G. More... | |
| void | fill (const T &x) |
Sets all array elements to x. More... | |
| NodeArray< T > & | operator= (const NodeArray< T > &a) |
| Assignment operator. More... | |
| NodeArray< T > & | operator= (NodeArray< T > &&a) |
| Assignment operator (move semantics). More... | |
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 graph. More... | |
| 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... | |
Private Member Functions inherited from ogdf::Array< T > | |
| Array () | |
| Creates an array with empty index set. More... | |
| Array (int s) | |
Creates an array with index set [0..s-1]. 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 (std::initializer_list< T > initList) | |
Creates an array containing the elements in the initializer list initList. More... | |
| Array (const Array< T, int > &A) | |
Creates an array that is a copy of A. More... | |
| Array (Array< T, int > &&A) | |
Creates an array containing the elements of A (move semantics). 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 () | |
| 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... | |
| iterator | rbegin () |
| Returns an iterator to the last element. More... | |
| const_iterator | rbegin () const |
| Returns a const iterator to the last element. More... | |
| const_iterator | crbegin () const |
| Returns a const iterator to the last element. More... | |
| iterator | rend () |
| Returns an iterator to one before the first element. More... | |
| const_iterator | rend () const |
| Returns a const iterator to one before the first element. More... | |
| const_iterator | crend () const |
| Returns a const 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... | |
| 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... | |
Private Attributes | |
| T | m_x |
| The default value for array elements. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ogdf::NodeArrayBase | |
| NodeArrayBase () | |
| Initializes an node array not associated with a graph. More... | |
| NodeArrayBase (const Graph *pG) | |
Initializes an node array associated with pG. More... | |
| NodeArrayBase (NodeArrayBase &base) | |
Moves node array base to this node array. More... | |
| virtual | ~NodeArrayBase () |
| void | moveRegister (NodeArrayBase &base) |
Moves array registration from base to this array. More... | |
| void | reregister (const Graph *pG) |
| Associates the array with a new graph. More... | |
Protected Attributes inherited from ogdf::NodeArrayBase | |
| const Graph * | m_pGraph |
| The associated graph. More... | |
Private Types inherited from ogdf::Array< T > | |
| using | const_iterator = const 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 | iterator = 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 | value_type = T |
| Represents the data type stored in an array element. 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... | |
Dynamic arrays indexed with nodes.
NodeArrays represent a mapping from nodes to data of type T. They adjust their table size automatically when the graph grows.
| T | is the element type. |
| using ogdf::NodeArray< T >::const_iterator = internal::GraphArrayConstIterator<NodeArray<T> > |
The type for node array const iterators.
Definition at line 120 of file NodeArray.h.
| using ogdf::NodeArray< T >::iterator = internal::GraphArrayIterator<NodeArray<T> > |
The type for node array iterators.
Definition at line 119 of file NodeArray.h.
| using ogdf::NodeArray< T >::key_type = node |
The type for array keys.
Definition at line 116 of file NodeArray.h.
| using ogdf::NodeArray< T >::value_type = T |
The type for array entries.
Definition at line 117 of file NodeArray.h.
|
inline |
Constructs an empty node array associated with no graph.
Definition at line 124 of file NodeArray.h.
|
inline |
Constructs a node array associated with G.
Definition at line 127 of file NodeArray.h.
|
inline |
Constructs a node array associated with G.
| G | is the associated graph. |
| x | is the default value for all array elements. |
Definition at line 134 of file NodeArray.h.
|
inline |
Constructs a node array that is a copy of A.
Associates the array with the same graph as A and copies all elements.
Definition at line 141 of file NodeArray.h.
|
inline |
Constructs a node array containing the elements of A (move semantics).
NodeArray A is empty afterwards and not associated with any graph.
Definition at line 147 of file NodeArray.h.
|
inline |
Returns an iterator to the first entry in the node array.
If the node array is empty, an invalid iterator is returned.
Definition at line 215 of file NodeArray.h.
|
inline |
Returns a const iterator to the first entry in the node array.
If the node array is empty, an invalid iterator is returned.
Definition at line 221 of file NodeArray.h.
|
inline |
Returns a const iterator to the first entry in the node array.
If the node array is empty, an invalid iterator is returned.
Definition at line 227 of file NodeArray.h.
|
inline |
Returns a const iterator to one-past-last entry in the node array.
This is always an invalid iterator.
Definition at line 245 of file NodeArray.h.
|
inline |
Returns a const iterator to the last entry in the node array.
If the node array is empty, an invalid iterator is returned.
Definition at line 263 of file NodeArray.h.
|
inline |
Returns a const iterator to one-before-first entry in the node array.
This is always an invalid iterator.
Definition at line 281 of file NodeArray.h.
|
inlineprivatevirtual |
Virtual function called when array is disconnected from the graph.
Implements ogdf::NodeArrayBase.
Definition at line 358 of file NodeArray.h.
|
inline |
Returns an iterator to one-past-last entry in the node array.
This is always an invalid iterator.
Definition at line 233 of file NodeArray.h.
|
inline |
Returns a const iterator to one-past-last entry in the node array.
This is always an invalid iterator.
Definition at line 239 of file NodeArray.h.
|
inlineprivatevirtual |
Virtual function called when table size has to be enlarged.
Implements ogdf::NodeArrayBase.
Definition at line 350 of file NodeArray.h.
|
inline |
Sets all array elements to x.
Definition at line 311 of file NodeArray.h.
|
inlinestatic |
Definition at line 345 of file NodeArray.h.
|
inlinestatic |
Definition at line 344 of file NodeArray.h.
|
inline |
Returns a pointer to the associated graph.
Definition at line 160 of file NodeArray.h.
|
inline |
Reinitializes the array. Associates the array with no graph.
Definition at line 292 of file NodeArray.h.
|
inline |
Reinitializes the array. Associates the array with G.
Definition at line 297 of file NodeArray.h.
|
inline |
Reinitializes the array. Associates the array with G.
| G | is the associated graph. |
| x | is the default value. |
Definition at line 306 of file NodeArray.h.
|
inline |
Returns a reference to the element with index v.
Definition at line 179 of file NodeArray.h.
|
inline |
Returns a reference to the element with index v.
Definition at line 186 of file NodeArray.h.
|
inline |
Assignment operator.
Definition at line 318 of file NodeArray.h.
|
inline |
Assignment operator (move semantics).
Nodearray a is empty afterwards and not associated with any graph.
Definition at line 329 of file NodeArray.h.
|
inline |
Returns a reference to the element with index v.
Definition at line 165 of file NodeArray.h.
|
inline |
Returns a reference to the element with index v.
Definition at line 172 of file NodeArray.h.
|
inline |
Returns a reference to the element with index index.
index is a valid index for a node in the associated graph! Definition at line 195 of file NodeArray.h.
|
inline |
Returns a reference to the element with index index.
index is a valid index for a node in the associated graph! Definition at line 201 of file NodeArray.h.
|
inline |
Returns an iterator to the last entry in the node array.
If the node array is empty, an invalid iterator is returned.
Definition at line 251 of file NodeArray.h.
|
inline |
Returns a const iterator to the last entry in the node array.
If the node array is empty, an invalid iterator is returned.
Definition at line 257 of file NodeArray.h.
|
inlineprivatevirtual |
Virtual function called when table has to be reinitialized.
Implements ogdf::NodeArrayBase.
Definition at line 354 of file NodeArray.h.
|
inline |
Returns an iterator to one-before-first entry in the node array.
This is always an invalid iterator.
Definition at line 269 of file NodeArray.h.
|
inline |
Returns a const iterator to one-before-first entry in the node array.
This is always an invalid iterator.
Definition at line 275 of file NodeArray.h.
|
inline |
Returns true iff the array is associated with a graph.
Definition at line 157 of file NodeArray.h.
|
private |
The default value for array elements.
Definition at line 113 of file NodeArray.h.