Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

nonduplpool.h
Go to the documentation of this file.
1 
30 #pragma once
31 
32 #include <ogdf/lib/abacus/hash.h>
35 #include <ogdf/lib/abacus/master.h>
39 #include <ogdf/lib/abacus/sub.h>
40 #include <ogdf/lib/abacus/bheap.h>
41 
42 namespace abacus {
43 
45 
57 template<class BaseType, class CoType>
58 class NonDuplPool : public StandardPool<BaseType, CoType> {
59 public:
60 
62 
69  NonDuplPool(Master *master, int size, bool autoRealloc = false)
70  : StandardPool<BaseType, CoType>(master, size, autoRealloc), hash_(size), nDuplications_(0)
71  { }
72 
74  virtual ~NonDuplPool() {
75 #ifdef OGDF_DEBUG
76  Logger::ifout() << "Number of duplicated constraints: " <<
77  nDuplications_ << std::endl;
78 #endif
79  }
80 
82 
93  virtual PoolSlot<BaseType, CoType> *insert(BaseType *cv);
94 
96 
104  virtual PoolSlot<BaseType, CoType> *present(BaseType *cv);
105 
107 
115  virtual const PoolSlot<BaseType, CoType> *present(const BaseType *cv) const;
116 
118 
125  virtual void increase(int size) {
127  hash_.resize(size);
128  }
129 
131 
144  void statistics(int &nDuplications, int &nCollisions) const {
145  nDuplications = nDuplications_;
146  nCollisions = hash_.nCollisions();
147 }
148 
149 private:
150 
161 
168  virtual void hardDeleteConVar(PoolSlot<BaseType, CoType> *slot);
169 
172 
176 
177 
178  NonDuplPool(const NonDuplPool &rhs);
179  const NonDuplPool &operator=(const NonDuplPool &rhs);
180 };
181 
182 }
183 
Hash tables.
Definition: hash.h:38
int size() const
Return the maximal number of constraints/variables that can be inserted in the pool.
Definition: standardpool.h:121
virtual void increase(int size)
Enlarges the pool to store up to size items.
Standard pools without constraint duplication.
Definition: nonduplpool.h:58
The master of the optimization.
Definition: master.h:69
virtual int softDeleteConVar(PoolSlot< BaseType, CoType > *slot)
Has to be redefined because the slot has to be removed from the hash table if the constraint/variable...
PoolSlot< BaseType, CoType > * slot(int i)
Returns a pointer to the i-th slot in the pool.
Definition: standardpool.h:127
virtual PoolSlot< BaseType, CoType > * present(BaseType *cv)
Checks if constraint/variables cv is already contained in the pool.
AbaHash< unsigned, PoolSlot< BaseType, CoType > * > hash_
A hash table for a fast access to the pool slot storing a constraint/variable.
Definition: nonduplpool.h:171
virtual void hardDeleteConVar(PoolSlot< BaseType, CoType > *slot)
Has to be redefined because the pool slot has to be removed from the hash table.
standard pool.
int nDuplications_
The number of insertions of constraints/variables that were rejected since the constraint/variable is...
Definition: nonduplpool.h:175
hash table.
NonDuplPool(Master *master, int size, bool autoRealloc=false)
Creates an empty pool.
Definition: nonduplpool.h:69
the master of the optimization.
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition: Logger.h:194
virtual ~NonDuplPool()
The destructor.
Definition: nonduplpool.h:74
constraint.
void statistics(int &nDuplications, int &nCollisions) const
Returns some statistic information in nDuplicates and nCollisions.
Definition: nonduplpool.h:144
poolslot.
Stores constraints and variables.
Definition: active.h:39
variable.
virtual void increase(int size)
Enlarges the pool to store up to size items.
Definition: nonduplpool.h:125
virtual PoolSlot< BaseType, CoType > * insert(BaseType *cv)
Insert constraint/variable cv in the pool.
const NonDuplPool & operator=(const NonDuplPool &rhs)
Standard pools.
Definition: convar.h:44
cutbuffer.