Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

ogdf::NodeArray< T > Class Template Reference

Dynamic arrays indexed with nodes. More...

#include <ogdf/basic/Graph_d.h>

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 GraphgraphOf () 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...
 
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...
 

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 void reinit (int initTableSize)
 
virtual void disconnect ()
 

Detailed Description

template<class T>
class ogdf::NodeArray< T >

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.

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 441 of file Graph_d.h.

Member Typedef Documentation

◆ const_iterator

The type for node array const iterators.

Definition at line 120 of file NodeArray.h.

◆ iterator

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

The type for node array iterators.

Definition at line 119 of file NodeArray.h.

◆ key_type

template<class T >
using ogdf::NodeArray< T >::key_type = node

The type for array keys.

Definition at line 116 of file NodeArray.h.

◆ value_type

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

The type for array entries.

Definition at line 117 of file NodeArray.h.

Constructor & Destructor Documentation

◆ NodeArray() [1/5]

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

Constructs an empty node array associated with no graph.

Definition at line 124 of file NodeArray.h.

◆ NodeArray() [2/5]

template<class T >
ogdf::NodeArray< T >::NodeArray ( const Graph G)
inline

Constructs a node array associated with G.

Definition at line 127 of file NodeArray.h.

◆ NodeArray() [3/5]

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

Constructs a node array associated with G.

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

Definition at line 134 of file NodeArray.h.

◆ NodeArray() [4/5]

template<class T >
ogdf::NodeArray< T >::NodeArray ( const NodeArray< T > &  A)
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.

◆ NodeArray() [5/5]

template<class T >
ogdf::NodeArray< T >::NodeArray ( NodeArray< T > &&  A)
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.

Member Function Documentation

◆ begin() [1/2]

template<class T >
iterator ogdf::NodeArray< T >::begin ( )
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.

◆ begin() [2/2]

template<class T >
const_iterator ogdf::NodeArray< T >::begin ( ) const
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.

◆ cbegin()

template<class T >
const_iterator ogdf::NodeArray< T >::cbegin ( ) const
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.

◆ cend()

template<class T >
const_iterator ogdf::NodeArray< T >::cend ( ) const
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.

◆ disconnect()

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

Definition at line 321 of file NodeArray.h.

◆ end() [1/2]

template<class T >
iterator ogdf::NodeArray< T >::end ( )
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.

◆ end() [2/2]

template<class T >
const_iterator ogdf::NodeArray< T >::end ( ) const
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.

◆ enlargeTable()

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

Definition at line 313 of file NodeArray.h.

◆ fill()

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

Sets all array elements to x.

Definition at line 274 of file NodeArray.h.

◆ findPredKey()

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

Definition at line 308 of file NodeArray.h.

◆ findSuccKey()

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

Definition at line 307 of file NodeArray.h.

◆ graphOf()

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

Returns a pointer to the associated graph.

Definition at line 160 of file NodeArray.h.

◆ init() [1/3]

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

Reinitializes the array. Associates the array with no graph.

Definition at line 255 of file NodeArray.h.

◆ init() [2/3]

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

Reinitializes the array. Associates the array with G.

Definition at line 260 of file NodeArray.h.

◆ init() [3/3]

template<class T >
void ogdf::NodeArray< 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 269 of file NodeArray.h.

◆ operator()() [1/2]

template<class T >
T& ogdf::NodeArray< T >::operator() ( node  v)
inline

Returns a reference to the element with index v.

Definition at line 186 of file NodeArray.h.

◆ operator()() [2/2]

template<class T >
const T& ogdf::NodeArray< T >::operator() ( node  v) const
inline

Returns a reference to the element with index v.

Definition at line 179 of file NodeArray.h.

◆ operator=() [1/2]

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

Assignment operator.

Definition at line 281 of file NodeArray.h.

◆ operator=() [2/2]

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

Assignment operator (move semantics).

Nodearray a is empty afterwards and not associated with any graph.

Definition at line 292 of file NodeArray.h.

◆ operator[]() [1/4]

template<class T >
T& ogdf::NodeArray< 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 node in the associated graph!
Deprecated:
"NodeArrays should be indexed by a node, not an integer index."

Definition at line 201 of file NodeArray.h.

◆ operator[]() [2/4]

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

Definition at line 195 of file NodeArray.h.

◆ operator[]() [3/4]

template<class T >
T& ogdf::NodeArray< T >::operator[] ( node  v)
inline

Returns a reference to the element with index v.

Definition at line 172 of file NodeArray.h.

◆ operator[]() [4/4]

template<class T >
const T& ogdf::NodeArray< T >::operator[] ( node  v) const
inline

Returns a reference to the element with index v.

Definition at line 165 of file NodeArray.h.

◆ reinit()

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

Definition at line 317 of file NodeArray.h.

◆ valid()

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

Returns true iff the array is associated with a graph.

Definition at line 157 of file NodeArray.h.

Member Data Documentation

◆ m_x

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

The default value for array elements.

Definition at line 113 of file NodeArray.h.


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