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())) {
152 sort<TaskView,STO_EST,true>(map,
tasks);
154 for (
int i=
tasks.size();
i--; )
159 while (fst <
tasks.size())
163 for (
int i=
tasks.size();
i--; )
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--; )
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.
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.
int n_inner(void) const
Return number of inner nodes.
const int infinity
Infinity for integers.
bool n_leaf(int i) const
Whether node i is leaf.
Node * x
Pointer to corresponding Boolean expression node.
static bool left(int i)
Test whether node i is a left child.
void free(T *b, long unsigned int n)
Delete n objects allocated from the region starting at b.
Node & leaf(int i)
Return leaf for task i.
static bool n_root(int i)
Whether node i is index of root.
Gecode toplevel namespace
const Node & root(void) const
Return root node.
const TaskViewArray< TaskView > & tasks
The tasks from which the tree is computed.
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.