Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

active.inc
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <ogdf/lib/abacus/active.h>
32 #include <ogdf/lib/abacus/master.h>
35 #include <ogdf/lib/abacus/convar.h>
37 
38 #pragma GCC visibility push(default)
39 namespace abacus {
40 
41 template <class BaseType, class CoType>
43  Master *master,
44  Active<BaseType, CoType> *a,
45  int max)
46  :
47 master_(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 
59 template <class BaseType, class CoType>
60 Active<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 
74 template <class BaseType, class CoType>
75 Active<BaseType, CoType>::~Active()
76 {
77  for (int i = 0; i < n_; i++)
78  delete active_[i];
79 }
80 
81 
82 template <class BaseType, class CoType>
83 std::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 
97 template <class BaseType, class CoType>
98 void 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 
108 template <class BaseType, class CoType>
109 void 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 
119 template <class BaseType, class CoType>
120 void 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 
132 template <class BaseType, class CoType>
133 void Active<BaseType, CoType>::realloc(int newSize)
134 {
135  active_.resize(newSize);
136  redundantAge_.resize(newSize);
137 }
138 
139 }
140 #pragma GCC visibility pop
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
convar.h
constraints and variables.
abacus
Definition: ILPClusterPlanarity.h:50
poolslotref.h
poolslotref
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:983
active.h
sparvec.h
sparse vector.
abacus::Active::Active
Active(Master *master, int max)
Creates an empty set of active items.
Definition: active.h:71
master.h
the master of the optimization.
poolslot.h
poolslot.
Minisat::Internal::remove
static void remove(V &ts, const T &t)
Definition: Alg.h:37