Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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