Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

ogdf::HashArray2D< I1, I2, E, H1, H2 > Class Template Reference

Indexed 2-dimensional arrays using hashing for element access. More...

#include <ogdf/basic/HashArray2D.h>

+ Inheritance diagram for ogdf::HashArray2D< I1, I2, E, H1, H2 >:

Public Types

using const_iterator = HashConstIterator2D< I1, I2, E, H1, H2 >
 The type of const-iterators for 2D-hash arrays. More...
 

Public Member Functions

 HashArray2D ()
 Creates a 2D-hash array. More...
 
 HashArray2D (const E &defaultValue, const H1 &hashFunc1=H1(), const H2 &hashFunc2=H2())
 Creates a 2D-hash array and sets the default value to defaultValue. More...
 
 HashArray2D (const HashArray2D< I1, I2, E, H1, H2 > &A)
 Copy constructor. More...
 
 ~HashArray2D ()
 
HashConstIterator2D< I1, I2, E, H1, H2 > begin () const
 Returns an iterator pointing to the first element. More...
 
void clear ()
 Undefines all indices. More...
 
int empty () const
 Returns if any indices are defined. More...
 
bool isDefined (const I1 &i, const I2 &j) const
 Returns true iff entry (i,j) is defined. More...
 
E & operator() (const I1 &i, const I2 &j)
 Returns a reference to entry (i,j). More...
 
const E & operator() (const I1 &i, const I2 &j) const
 Returns a const reference to entry (i,j). More...
 
HashArray2Doperator= (const HashArray2D< I1, I2, E, H1, H2 > &A)
 Assignment operator. More...
 
int size () const
 Returns the number of defined elements in the table. More...
 
void undefine (const I1 &i, const I2 &j)
 Undefines the entry at index (i,j). More...
 

Private Attributes

m_defaultValue
 The default value of the array. More...
 

Additional Inherited Members

- Private Types inherited from ogdf::Hashing< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > >
using const_iterator = HashConstIterator< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > >
 The type of const-iterators for hash tables. More...
 
- Private Member Functions inherited from ogdf::Hashing< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > >
 Hashing (const Hashing< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > > &h)=default
 Copy constructor. More...
 
 Hashing (int minTableSize=256, const HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > &hashFunc=HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > >())
 Creates a hash table for given initial table size minTableSize. More...
 
 ~Hashing ()
 Destruction. More...
 
HashConstIterator< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > > begin () const
 Returns an hash iterator to the first element in the list of all elements. More...
 
void clear ()
 Removes all elements from the hash table. More...
 
void del (const Tuple2< I1, I2 > &key)
 Removes the element with key key from the hash table (does nothing if no such element). More...
 
bool empty () const
 Returns true iff the table is empty, i.e., contains no elements. More...
 
HashElement< Tuple2< I1, I2 >, E > * fastInsert (const Tuple2< I1, I2 > &key, const E &info)
 Inserts a new element with key key and information info into the hash table. More...
 
HashElement< Tuple2< I1, I2 >, E > * insert (const Tuple2< I1, I2 > &key, const E &info)
 Inserts a new element with key key and information info into the hash table. More...
 
HashElement< Tuple2< I1, I2 >, E > * insertByNeed (const Tuple2< I1, I2 > &key, const E &info)
 Inserts a new element with key key and information info into the hash table. More...
 
HashElement< Tuple2< I1, I2 >, E > * lookup (const Tuple2< I1, I2 > &key) const
 Returns the hash element with key key in the hash table; returns nullptr if no such element exists. More...
 
bool member (const Tuple2< I1, I2 > &key) const
 Returns true iff the hash table contains an element with key key. More...
 
Hashing< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > > & operator= (const Hashing< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > > &hashing)=default
 Assignment operator. More...
 
int size () const
 Returns the number of elements in the hash table. More...
 
HashElement< Tuple2< I1, I2 >, E > * firstElement (HashElement< Tuple2< I1, I2 >, E > ***pList) const
 Returns the first element in the list of all elements in the hash table. More...
 
HashElement< Tuple2< I1, I2 >, E > * nextElement (HashElement< Tuple2< I1, I2 >, E > ***pList, HashElement< Tuple2< I1, I2 >, E > *pElement) const
 Returns the successor of pElement in the list of all elements in the hash table. More...
 

Detailed Description

template<class I1, class I2, class E, class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
class ogdf::HashArray2D< I1, I2, E, H1, H2 >

Indexed 2-dimensional arrays using hashing for element access.

Template Parameters
I1is the first index type.
I2is the second index type.
Eis the element type.
H1is the hash function type for I1. Optional; uses the class DefHashFunc by default.
H2is the hash function type for I2. Optional; uses the class DefHashFunc by default.

A 2D-hash array can be used like a usual 2-dimensional array but with a general index type.

Definition at line 65 of file HashArray2D.h.

Member Typedef Documentation

◆ const_iterator

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
using ogdf::HashArray2D< I1, I2, E, H1, H2 >::const_iterator = HashConstIterator2D<I1,I2,E,H1,H2>

The type of const-iterators for 2D-hash arrays.

Definition at line 69 of file HashArray2D.h.

Constructor & Destructor Documentation

◆ HashArray2D() [1/3]

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
ogdf::HashArray2D< I1, I2, E, H1, H2 >::HashArray2D ( )
inline

Creates a 2D-hash array.

Definition at line 72 of file HashArray2D.h.

◆ HashArray2D() [2/3]

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
ogdf::HashArray2D< I1, I2, E, H1, H2 >::HashArray2D ( const E &  defaultValue,
const H1 &  hashFunc1 = H1(),
const H2 &  hashFunc2 = H2() 
)
inlineexplicit

Creates a 2D-hash array and sets the default value to defaultValue.

Definition at line 75 of file HashArray2D.h.

◆ HashArray2D() [3/3]

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
ogdf::HashArray2D< I1, I2, E, H1, H2 >::HashArray2D ( const HashArray2D< I1, I2, E, H1, H2 > &  A)
inline

Copy constructor.

Definition at line 82 of file HashArray2D.h.

◆ ~HashArray2D()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
ogdf::HashArray2D< I1, I2, E, H1, H2 >::~HashArray2D ( )
inline

Definition at line 94 of file HashArray2D.h.

Member Function Documentation

◆ begin()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
HashConstIterator2D<I1,I2,E,H1,H2> ogdf::HashArray2D< I1, I2, E, H1, H2 >::begin ( ) const
inline

Returns an iterator pointing to the first element.

Definition at line 124 of file HashArray2D.h.

◆ clear()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
void ogdf::HashArray2D< I1, I2, E, H1, H2 >::clear ( )
inline

Undefines all indices.

Definition at line 141 of file HashArray2D.h.

◆ empty()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
int ogdf::HashArray2D< I1, I2, E, H1, H2 >::empty ( ) const
inline

Returns if any indices are defined.

Definition at line 135 of file HashArray2D.h.

◆ isDefined()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
bool ogdf::HashArray2D< I1, I2, E, H1, H2 >::isDefined ( const I1 &  i,
const I2 &  j 
) const
inline

Returns true iff entry (i,j) is defined.

Definition at line 114 of file HashArray2D.h.

◆ operator()() [1/2]

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
E& ogdf::HashArray2D< I1, I2, E, H1, H2 >::operator() ( const I1 &  i,
const I2 &  j 
)
inline

Returns a reference to entry (i,j).

Definition at line 104 of file HashArray2D.h.

◆ operator()() [2/2]

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
const E& ogdf::HashArray2D< I1, I2, E, H1, H2 >::operator() ( const I1 &  i,
const I2 &  j 
) const
inline

Returns a const reference to entry (i,j).

Definition at line 97 of file HashArray2D.h.

◆ operator=()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
HashArray2D& ogdf::HashArray2D< I1, I2, E, H1, H2 >::operator= ( const HashArray2D< I1, I2, E, H1, H2 > &  A)
inline

Assignment operator.

Definition at line 87 of file HashArray2D.h.

◆ size()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
int ogdf::HashArray2D< I1, I2, E, H1, H2 >::size ( ) const
inline

Returns the number of defined elements in the table.

Definition at line 130 of file HashArray2D.h.

◆ undefine()

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
void ogdf::HashArray2D< I1, I2, E, H1, H2 >::undefine ( const I1 &  i,
const I2 &  j 
)
inline

Undefines the entry at index (i,j).

Definition at line 119 of file HashArray2D.h.

Member Data Documentation

◆ m_defaultValue

template<class I1 , class I2 , class E , class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
E ogdf::HashArray2D< I1, I2, E, H1, H2 >::m_defaultValue
private

The default value of the array.

Definition at line 146 of file HashArray2D.h.


The documentation for this class was generated from the following file: