40 namespace Gecode {
namespace Int {
49 plus(
long long int x,
long long int y) {
54 template<
class TaskView,
class Node>
57 return tasks.size()-1;
59 template<
class TaskView,
class Node>
62 return 2*tasks.size() - 1;
65 template<
class TaskView,
class Node>
70 template<
class TaskView,
class Node>
73 return i >= n_inner();
75 template<
class TaskView,
class Node>
80 template<
class TaskView,
class Node>
87 template<
class TaskView,
class Node>
92 template<
class TaskView,
class Node>
99 template<
class TaskView,
class Node>
105 template<
class TaskView,
class Node>
108 return node[_leaf[
i]];
111 template<
class TaskView,
class Node>
117 template<
class TaskView,
class Node>
120 for (
int i=n_inner();
i--; )
121 node[
i].init(node[n_left(
i)],node[n_right(
i)]);
124 template<
class TaskView,
class Node>
127 for (
int i=n_inner();
i--; )
128 node[
i].
update(node[n_left(
i)],node[n_right(
i)]);
131 template<
class TaskView,
class Node>
139 node[
i].update(node[n_left(i)],node[n_right(i)]);
140 }
while (!n_root(i));
143 template<
class TaskView,
class Node>
148 node(r.alloc<Node>(n_nodes())),
149 _leaf(r.alloc<int>(tasks.
size())) {
151 int* map = r.
alloc<
int>(tasks.size());
152 sort<TaskView,STO_EST,true>(map, tasks);
154 for (
int i=tasks.
size();
i--; )
156 r.
free<
int>(map,tasks.size());
159 while (fst < tasks.size())
163 for (
int i=tasks.
size();
i--; )
164 if (_leaf[
i] + fst >= n_nodes())
165 _leaf[
i] += fst - tasks.size();
170 template<
class TaskView,
class Node>
template<
class Node2>
175 node(r.alloc<Node>(n_nodes())),
176 _leaf(r.alloc<int>(tasks.
size())) {
177 for (
int 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.
Gecode::IntArgs i(4, 1, 2, 3, 4)
static int n_parent(int i)
Return index of parent of node i.
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)