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
active.inc
Go to the documentation of this file.
1
29#pragma once
30
37
38namespace abacus {
39
40template <class BaseType, class CoType>
42 Master *master,
44 int max)
45 :
46master_(master),
47 n_(0),
48 active_(max),
49 redundantAge_(0,max-1, 0)
50{
51 n_ = (max < a->number()) ? max : a->number();
52
53 for (int i = 0; i < n_; i++)
54 active_[i] = new PoolSlotRef<BaseType, CoType>(*(a->active_[i]));
55}
56
57
58template <class BaseType, class CoType>
59Active<BaseType, CoType>::Active(const Active<BaseType, CoType> &rhs)
60 :
61 master_(rhs.master_),
62 n_(rhs.n_),
63 active_(/*rhs.master_,*/ rhs.max()),
64 redundantAge_(/*master_*/0, rhs.max()-1, 0)
65{
66 for (int i = 0; i < n_; i++) {
67 active_[i] = new PoolSlotRef<BaseType, CoType>(*(rhs.active_[i]));
68 redundantAge_[i] = rhs.redundantAge_[i];
69 }
70}
71
72
73template <class BaseType, class CoType>
74Active<BaseType, CoType>::~Active()
75{
76 for (int i = 0; i < n_; i++)
77 delete active_[i];
78}
79
80
81template <class BaseType, class CoType>
82std::ostream &operator<<(std::ostream &out, const Active<BaseType, CoType> &rhs)
83{
84 for (int i = 0; i < rhs.n_; i++) {
85 out << i << ": ";
86 BaseType *cv = rhs.active_[i]->conVar();
87 if (cv != 0)
88 cv->print(out);
89 else
90 out << "void" << std::endl;
91 }
92 return out;
93}
94
95
96template <class BaseType, class CoType>
97void Active<BaseType, CoType>::insert(PoolSlot<BaseType, CoType> *ps)
98{
99 OGDF_ASSERT(n_ != max()); // buffer is full
100
101 active_[n_] = new PoolSlotRef<BaseType, CoType>(ps);
102 redundantAge_[n_] = 0;
103 n_++;
104}
105
106
107template <class BaseType, class CoType>
108void Active<BaseType, CoType>::insert(
109 ArrayBuffer<PoolSlot<BaseType, CoType> *> &ps)
110{
111 const int nPs = ps.size();
112
113 for(int i = 0; i < nPs; i++)
114 insert(ps[i]);
115}
116
117
118template <class BaseType, class CoType>
119void Active<BaseType, CoType>::remove(ArrayBuffer<int> &del)
120{
121 const int nDel = del.size();
122
123 for(int i = 0; i < nDel; i++)
124 delete active_[del[i]];
125 active_.leftShift(del);
126 redundantAge_.leftShift(del);
127 n_ -= nDel;
128}
129
130
131template <class BaseType, class CoType>
132void Active<BaseType, CoType>::realloc(int newSize)
133{
134 active_.resize(newSize);
135 redundantAge_.resize(newSize);
136}
137
138}
Active(Master *master, int max)
Creates an empty set of active items.
Definition active.h:70
constraints and variables.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
the master of the optimization.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:978
poolslot.
poolslotref
sparse vector.