Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

ogdf::EdgeArray< T > Class Template Reference

Dynamic arrays indexed with edges. More...

#include <ogdf/basic/EdgeArray.h>

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

Public Types

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

Public Member Functions

 EdgeArray ()
 Constructs an empty edge array associated with no graph. More...
 
 EdgeArray (const EdgeArray< T > &A)
 Constructs an edge array that is a copy of A. More...
 
 EdgeArray (const Graph &G)
 Constructs an edge array associated with G. More...
 
 EdgeArray (const Graph &G, const T &x)
 Constructs an edge array associated with G. More...
 
 EdgeArray (EdgeArray< T > &&A)
 Constructs an edge array containing the elements of A (move semantics). More...
 
Access methods

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

bool valid () const
 Returns true iff the array is associated with a graph. More...
 
const GraphgraphOf () const
 Returns a pointer to the associated graph. More...
 
const T & operator[] (edge e) const
 Returns a reference to the element with index e. More...
 
T & operator[] (edge e)
 Returns a reference to the element with index e. More...
 
const T & operator() (edge e) const
 Returns a reference to the element with index e. More...
 
T & operator() (edge e)
 Returns a reference to the element with index e. More...
 
const T & operator[] (adjEntry adj) const
 Returns a reference to the element with index edge of adj. More...
 
T & operator[] (adjEntry adj)
 Returns a reference to the element with index edge of adj. More...
 
const T & operator() (adjEntry adj) const
 Returns a reference to the element with index edge of adj. More...
 
T & operator() (adjEntry adj)
 Returns a reference to the element with index edge of adj. 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 edge array. More...
 
const_iterator begin () const
 Returns a const iterator to the first entry in the edge array. More...
 
const_iterator cbegin () const
 Returns a const iterator to the first entry in the edge array. More...
 
iterator end ()
 Returns an iterator to one-past-last entry in the edge array. More...
 
const_iterator end () const
 Returns a const iterator to one-past-last entry in the edge array. More...
 
const_iterator cend () const
 Returns a const iterator to one-past-last entry in the edge 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...
 
EdgeArray< T > & operator= (const EdgeArray< T > &a)
 Assignment operator. More...
 
EdgeArray< T > & operator= (EdgeArray< 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 graph. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ogdf::EdgeArrayBase
 EdgeArrayBase ()
 Initializes an edge array not associated with a graph. More...
 
 EdgeArrayBase (const Graph *pG)
 Initializes an edge array associated with pG. More...
 
 EdgeArrayBase (EdgeArrayBase &base)
 Moves edge array base to this edge array. More...
 
virtual ~EdgeArrayBase ()
 
void moveRegister (EdgeArrayBase &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::EdgeArrayBase
const Graphm_pGraph
 The associated 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::EdgeArray< T >

Dynamic arrays indexed with edges.

Edge arrays represent a mapping from edges to data of type T. They adjust their table size automatically when the 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);
Template Parameters
Tis the element type.

Definition at line 112 of file EdgeArray.h.

Member Typedef Documentation

◆ const_iterator

The type for edge array const iterators.

Definition at line 124 of file EdgeArray.h.

◆ iterator

template<class T >
using ogdf::EdgeArray< T >::iterator = internal::GraphArrayIterator<EdgeArray<T> >

The type for edge array iterators.

Definition at line 122 of file EdgeArray.h.

◆ key_type

template<class T >
using ogdf::EdgeArray< T >::key_type = edge

The type for array keys.

Definition at line 117 of file EdgeArray.h.

◆ value_type

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

The type for array entries.

Definition at line 119 of file EdgeArray.h.

Constructor & Destructor Documentation

◆ EdgeArray() [1/5]

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

Constructs an empty edge array associated with no graph.

Definition at line 128 of file EdgeArray.h.

◆ EdgeArray() [2/5]

template<class T >
ogdf::EdgeArray< T >::EdgeArray ( const Graph G)
inlineexplicit

Constructs an edge array associated with G.

Definition at line 131 of file EdgeArray.h.

◆ EdgeArray() [3/5]

template<class T >
ogdf::EdgeArray< T >::EdgeArray ( const Graph G,
const T &  x 
)
inline

Constructs an edge array associated with G.

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

Definition at line 138 of file EdgeArray.h.

◆ EdgeArray() [4/5]

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

Constructs an edge array that is a copy of A.

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

Definition at line 145 of file EdgeArray.h.

◆ EdgeArray() [5/5]

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

Constructs an edge array containing the elements of A (move semantics).

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

Definition at line 151 of file EdgeArray.h.

Member Function Documentation

◆ begin() [1/2]

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

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

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

Definition at line 243 of file EdgeArray.h.

◆ begin() [2/2]

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

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

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

Definition at line 249 of file EdgeArray.h.

◆ cbegin()

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

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

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

Definition at line 255 of file EdgeArray.h.

◆ cend()

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

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

This is always a null pointer iterator.

Definition at line 273 of file EdgeArray.h.

◆ disconnect()

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

Virtual function called when array is disconnected from the graph.

Implements ogdf::EdgeArrayBase.

Definition at line 349 of file EdgeArray.h.

◆ end() [1/2]

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

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

This is always a null pointer iterator.

Definition at line 261 of file EdgeArray.h.

◆ end() [2/2]

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

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

This is always a null pointer iterator.

Definition at line 267 of file EdgeArray.h.

◆ enlargeTable()

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

Virtual function called when table size has to be enlarged.

Implements ogdf::EdgeArrayBase.

Definition at line 341 of file EdgeArray.h.

◆ fill()

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

Sets all array elements to x.

Definition at line 302 of file EdgeArray.h.

◆ findPredKey()

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

Definition at line 336 of file EdgeArray.h.

◆ findSuccKey()

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

Definition at line 335 of file EdgeArray.h.

◆ graphOf()

template<class T >
const Graph* ogdf::EdgeArray< T >::graphOf ( ) const
inline

Returns a pointer to the associated graph.

Definition at line 164 of file EdgeArray.h.

◆ init() [1/3]

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

Reinitializes the array. Associates the array with no graph.

Definition at line 283 of file EdgeArray.h.

◆ init() [2/3]

template<class T >
void ogdf::EdgeArray< T >::init ( const Graph G)
inline

Reinitializes the array. Associates the array with G.

Definition at line 288 of file EdgeArray.h.

◆ init() [3/3]

template<class T >
void ogdf::EdgeArray< T >::init ( const Graph G,
const T &  x 
)
inline

Reinitializes the array. Associates the array with G.

Parameters
Gis the associated graph.
xis the default value.

Definition at line 297 of file EdgeArray.h.

◆ operator()() [1/4]

template<class T >
T& ogdf::EdgeArray< T >::operator() ( adjEntry  adj)
inline

Returns a reference to the element with index edge of adj.

Definition at line 215 of file EdgeArray.h.

◆ operator()() [2/4]

template<class T >
const T& ogdf::EdgeArray< T >::operator() ( adjEntry  adj) const
inline

Returns a reference to the element with index edge of adj.

Definition at line 209 of file EdgeArray.h.

◆ operator()() [3/4]

template<class T >
T& ogdf::EdgeArray< T >::operator() ( edge  e)
inline

Returns a reference to the element with index e.

Definition at line 190 of file EdgeArray.h.

◆ operator()() [4/4]

template<class T >
const T& ogdf::EdgeArray< T >::operator() ( edge  e) const
inline

Returns a reference to the element with index e.

Definition at line 183 of file EdgeArray.h.

◆ operator=() [1/2]

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

Assignment operator.

Definition at line 309 of file EdgeArray.h.

◆ operator=() [2/2]

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

Assignment operator (move semantics).

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

Definition at line 320 of file EdgeArray.h.

◆ operator[]() [1/6]

template<class T >
T& ogdf::EdgeArray< T >::operator[] ( adjEntry  adj)
inline

Returns a reference to the element with index edge of adj.

Definition at line 203 of file EdgeArray.h.

◆ operator[]() [2/6]

template<class T >
const T& ogdf::EdgeArray< T >::operator[] ( adjEntry  adj) const
inline

Returns a reference to the element with index edge of adj.

Definition at line 197 of file EdgeArray.h.

◆ operator[]() [3/6]

template<class T >
T& ogdf::EdgeArray< T >::operator[] ( edge  e)
inline

Returns a reference to the element with index e.

Definition at line 176 of file EdgeArray.h.

◆ operator[]() [4/6]

template<class T >
const T& ogdf::EdgeArray< T >::operator[] ( edge  e) const
inline

Returns a reference to the element with index e.

Definition at line 169 of file EdgeArray.h.

◆ operator[]() [5/6]

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

Returns a reference to the element with index index.

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

Definition at line 229 of file EdgeArray.h.

◆ operator[]() [6/6]

template<class T >
const T& ogdf::EdgeArray< 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 an edge in the associated graph!
Deprecated:
"Edge arrays should be indexed by an edge, not an integer index."

Definition at line 223 of file EdgeArray.h.

◆ reinit()

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

Virtual function called when table has to be reinitialized.

Implements ogdf::EdgeArrayBase.

Definition at line 345 of file EdgeArray.h.

◆ valid()

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

Returns true iff the array is associated with a graph.

Definition at line 161 of file EdgeArray.h.

Member Data Documentation

◆ m_x

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

The default value for array elements.

Definition at line 113 of file EdgeArray.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