Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
nonduplpool.inc
Go to the documentation of this file.
1
29#pragma once
30
32
33namespace abacus {
34
35
36template<class BaseType, class CoType>
38 BaseType *cv)
39{
40
42
43 slot = present(cv);
44 if (slot == nullptr) {
46 if (slot)
47 hash_.insert(cv->hashKey(), slot);
48 }
49 else {
50 delete cv;
51 nDuplications_++;
52 }
53 return slot;
54}
55
56
57template<class BaseType, class CoType>
59 BaseType *cv)
60{
61 int key = cv->hashKey();
62
63 PoolSlot<BaseType, CoType> **cand = hash_.initializeIteration(key);
64 while(cand) {
65 if (cv->equal((*cand)->conVar())) {
66 return *cand;
67 }
68 cand = hash_.next(key);
69 }
70 return nullptr;
71}
72
73template<class BaseType, class CoType>
75 const BaseType *cv) const
76{
77 int key = cv->hashKey();
78
79 PoolSlot<BaseType, CoType> *const *cand = hash_.initializeIteration(key);
80 while(cand) {
81 if (cv->equal((*cand)->conVar())) {
82 return *cand;
83 }
84 cand = hash_.next(key);
85 }
86 return nullptr;
87}
88
89template<class BaseType, class CoType>
91{
92 int key = slot->conVar()->hashKey();
93
95 if (hash_.remove(key, slot)) {
96 // Commented out in ABACUS 3.2
97#if 0
98 Logger::ifout() << "NonDuplPool::softDeleteCon(): slot not found in hash table.\n";
99 OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::afcNonDuplPool);
100#endif
101 }
102 return 0;
103 }
104 return 1;
105}
106
107
108template<class BaseType, class CoType>
111{
112 if (hash_.remove(slot->conVar()->hashKey(), slot)) {
113 // Commented out in ABACUS 3.2
114#if 0
115 Logger::ifout() << "NonDuplPool::hardDeleteConVar(): constraint not found in hash table.\n";
116 OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::afcNonDuplPool);
117#endif
118 }
120}
121
122}
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...
virtual PoolSlot< BaseType, CoType > * present(BaseType *cv)
Checks if constraint/variables cv is already contained in the pool.
virtual PoolSlot< BaseType, CoType > * insert(BaseType *cv)
Insert constraint/variable cv in the pool.
virtual void hardDeleteConVar(PoolSlot< BaseType, CoType > *slot)
Has to be redefined because the pool slot has to be removed from the hash table.
virtual void hardDeleteConVar(PoolSlot< BaseType, CoType > *slot)
Removes a constraint/variable from the pool and adds the slot to the set of free slots.
Definition pool.h:168
virtual int softDeleteConVar(PoolSlot< BaseType, CoType > *slot)
Removes the constraint/variable stored in slot from the pool if it can be deleted.
Definition pool.h:154
virtual PoolSlot< BaseType, CoType > * insert(BaseType *cv)
Tries to insert a constraint/variable in the pool.
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition Logger.h:192
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition exceptions.h:54
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
standard pool without constraint duplication.