36 namespace Gecode {
namespace Int {
45 plus(
long long int x,
long long int y) {
50 template<
class TaskView,
class Node>
53 return tasks.size()-1;
55 template<
class TaskView,
class Node>
58 return 2*tasks.size() - 1;
61 template<
class TaskView,
class Node>
66 template<
class TaskView,
class Node>
69 return i >= n_inner();
71 template<
class TaskView,
class Node>
76 template<
class TaskView,
class Node>
83 template<
class TaskView,
class Node>
88 template<
class TaskView,
class Node>
95 template<
class TaskView,
class Node>
101 template<
class TaskView,
class Node>
104 return node[_leaf[
i]];
107 template<
class TaskView,
class Node>
113 template<
class TaskView,
class Node>
116 for (
int i=n_inner();
i--; )
117 node[
i].init(node[n_left(
i)],node[n_right(
i)]);
120 template<
class TaskView,
class Node>
123 for (
int i=n_inner();
i--; )
124 node[
i].
update(node[n_left(
i)],node[n_right(
i)]);
127 template<
class TaskView,
class Node>
135 node[
i].update(node[n_left(i)],node[n_right(i)]);
136 }
while (!n_root(i));
139 template<
class TaskView,
class Node>
144 node(r.alloc<Node>(n_nodes())),
145 _leaf(r.alloc<int>(tasks.
size())) {
147 int* map = r.
alloc<
int>(tasks.size());
148 sort<TaskView,STO_EST,true>(map, tasks);
150 for (
int i=0;
i<tasks.
size();
i++)
152 r.
free<
int>(map,tasks.size());
155 while (fst < tasks.size())
159 for (
int i=0;
i<tasks.
size();
i++)
160 if (_leaf[
i] + fst >= n_nodes())
161 _leaf[
i] += fst - tasks.size();
166 template<
class TaskView,
class Node>
template<
class Node2>
171 node(r.alloc<Node>(n_nodes())),
172 _leaf(r.alloc<int>(tasks.
size())) {
173 for (
int i=0;
i<tasks.
size();
i++)
void free(void)
Free allocate memory.
static int n_right(int i)
Return index of right child of node i.
static int n_left(int i)
Return index of left child of node i.
int size(void) const
Return size of array (number of elements)
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
static bool right(int i)
Test whether node i is a right child.
static int n_parent(int i)
Return index of parent of node i.
Gecode::IntArgs i({1, 2, 3, 4})
void update(void)
Update all inner nodes of tree after leaves have been initialized.
void init(void)
Initialize tree after leaves have been initialized.
int plus(int x, int y)
Safe addition in case x is -IntLimits::infinity.
unsigned int size(I &i)
Size of all ranges of range iterator i.
int * _leaf
Map task number to leaf node number in right order.
bool n_leaf(int i) const
Whether node i is leaf.
Post propagator for SetVar SetOpType SetVar SetRelType r
const int infinity
Infinity for integers.
Post propagator for SetVar SetOpType SetVar y
int n_inner(void) const
Return number of inner nodes.
const Node & root(void) const
Return root node.
static bool left(int i)
Test whether node i is a left child.
Node & leaf(int i)
Return leaf for task i.
Post propagator for SetVar x
static bool n_root(int i)
Whether node i is index of root.
Gecode toplevel namespace
const long long int llinfinity
Infinity for long long integers.
int n_nodes(void) const
Return number of nodes for balanced binary tree.
Task trees for task views with node type Node.
void update(IntSet &y, Space &home, IntSet &py)