Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
HashArray2D.h
Go to the documentation of this file.
1
36#pragma once
37
40#include <ogdf/basic/tuples.h>
41
42namespace ogdf {
43
44
46
58template<class I1, class I2, class E, class H1 = DefHashFunc<I1>, class H2 = DefHashFunc<I2>>
59class HashArray2D : private Hashing<Tuple2<I1, I2>, E, HashFuncTuple<I1, I2, H1, H2>> {
60public:
63
66
68 explicit HashArray2D(const E& defaultValue, const H1& hashFunc1 = H1(),
69 const H2& hashFunc2 = H2())
70 : Hashing<Tuple2<I1, I2>, E, HashFuncTuple<I1, I2, H1, H2>>(256,
73
78
86
88
90 const E& operator()(const I1& i, const I2& j) const {
93 Tuple2<I1, I2>(i, j));
94 return (pElement) ? pElement->info() : m_defaultValue;
95 }
96
108
110 bool isDefined(const I1& i, const I2& j) const {
112 Tuple2<I1, I2>(i, j));
113 }
114
116 void undefine(const I1& i, const I2& j) {
118 }
119
125
128
131
134
135private:
137};
138
139}
Declaration and implementation of HashArray class.
Declaration of class HashIterator2D.
Indexed 2-dimensional arrays using hashing for element access.
Definition HashArray2D.h:59
HashArray2D()
Creates a 2D-hash array.
Definition HashArray2D.h:65
E m_defaultValue
The default value of the array.
int size() const
Returns the number of defined elements in the table.
HashArray2D(const HashArray2D< I1, I2, E, H1, H2 > &A)
Copy constructor.
Definition HashArray2D.h:75
int empty() const
Returns if any indices are defined.
const E & operator()(const I1 &i, const I2 &j) const
Returns a const reference to entry (i,j).
Definition HashArray2D.h:90
HashConstIterator2D< I1, I2, E, H1, H2 > begin() const
Returns an iterator pointing to the first element.
void clear()
Undefines all indices.
HashArray2D & operator=(const HashArray2D< I1, I2, E, H1, H2 > &A)
Assignment operator.
Definition HashArray2D.h:80
void undefine(const I1 &i, const I2 &j)
Undefines the entry at index (i,j).
E & operator()(const I1 &i, const I2 &j)
Returns a reference to entry (i,j).
Definition HashArray2D.h:98
bool isDefined(const I1 &i, const I2 &j) const
Returns true iff entry (i,j) is defined.
HashArray2D(const E &defaultValue, const H1 &hashFunc1=H1(), const H2 &hashFunc2=H2())
Creates a 2D-hash array and sets the default value to defaultValue.
Definition HashArray2D.h:68
Const-iterator for 2D-hash arrays.
Representation of elements in a hash table.
Definition Hashing.h:176
Hashing with chaining and table doubling.
Definition Hashing.h:261
void del(const K &key)
Removes the element with key key from the hash table (does nothing if no such element).
Definition Hashing.h:355
HashElement< K, I > * fastInsert(const K &key, const I &info)
Inserts a new element with key key and information info into the hash table.
Definition Hashing.h:348
bool member(const K &key) const
Returns true iff the hash table contains an element with key key.
Definition Hashing.h:286
HashElement< K, I > * lookup(const K &key) const
Returns the hash element with key key in the hash table; returns nullptr if no such element exists.
Definition Hashing.h:292
Tuples of two elements (2-tuples).
Definition tuples.h:46
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Declaration and implementation of class Tuple2, Tuple3 and Tuple4.