44 #include <initializer_list> 46 namespace Gecode {
namespace Kernel {
140 int size(
void)
const;
146 Var& operator [](
int i);
149 const Var& operator [](
int i)
const;
156 slice(
int start,
int inc=1,
int n=-1);
161 iterator begin(
void);
164 const_iterator begin(
void)
const;
168 const_iterator end(
void)
const;
170 reverse_iterator rbegin(
void);
172 const_reverse_iterator rbegin(
void)
const;
174 reverse_iterator rend(
void);
176 const_reverse_iterator rend(
void)
const;
188 static void*
operator new(size_t)
throw();
189 static void operator delete(
void*,size_t);
292 for (
int i=0;
i<
n;
i++)
310 for (
int i=0;
i<
n;
i++)
320 int size(
void)
const;
328 View& operator [](
int i);
331 const View& operator [](
int i)
const;
336 iterator begin(
void);
339 const_iterator begin(
void)
const;
343 const_iterator end(
void)
const;
345 reverse_iterator rbegin(
void);
347 const_reverse_iterator rbegin(
void)
const;
349 reverse_iterator rend(
void);
351 const_reverse_iterator rend(
void)
const;
384 void move_fst(
int i);
387 void move_lst(
int i);
416 void drop_fst(
int i);
419 void drop_lst(
int i);
457 bool same(
void)
const;
463 bool same(
const View&
y)
const;
468 static void*
operator new(size_t)
throw();
469 static void operator delete(
void*,size_t);
479 template<
class ViewX,
class ViewY>
487 template<
class ViewX,
class ViewY>
495 template<
class ViewX,
class ViewY>
528 static const int onstack_size = 16;
530 T onstack[onstack_size];
540 A concat(
const T& x)
const;
543 A& append(
const T& x);
553 A
slice(
int start,
int inc=1,
int n=-1);
592 template<
class InputIterator>
598 int size(
void)
const;
604 T& operator [](
int i);
607 const T& operator [](
int i)
const;
612 iterator begin(
void);
615 const_iterator begin(
void)
const;
619 const_iterator end(
void)
const;
621 reverse_iterator rbegin(
void);
623 const_reverse_iterator rbegin(
void)
const;
625 reverse_iterator rend(
void);
627 const_reverse_iterator rend(
void)
const;
693 template<
class InputIterator>
694 ArgArray(InputIterator first, InputIterator last);
700 slice(
int start,
int inc=1,
int n=-1);
709 operator <<(const ArgArray<T>&
x);
777 template<
class InputIterator>
778 VarArgArray(InputIterator first, InputIterator last);
784 slice(
int start,
int inc=1,
int n=-1);
793 operator <<(const VarArgArray<Var>&
x);
847 template<
class Char,
class Traits,
class Var>
848 std::basic_ostream<Char,Traits>&
849 operator <<(std::basic_ostream<Char,Traits>& os,
856 template<
class Char,
class Traits,
class View>
857 std::basic_ostream<Char,Traits>&
864 template<
class Char,
class Traits,
class T>
865 std::basic_ostream<Char,Traits>&
915 assert((i >= 0) && (i <
size()));
922 assert((i >= 0) && (i <
size()));
929 assert(
n==0 || start <
n);
936 s = (
n-start)/inc + ((
n-start) % inc == 0 ? 0 : 1);
938 s = (start+1)/-inc + ((start+1) % -inc == 0 ? 0 : 1);
940 for (
int i=0;
i<r.size();
i++, start+=inc)
999 for (
int i=0;
i<
n;
i++)
1009 for (
int i=0;
i<
n;
i++)
1030 for (
int i=0;
i<x.
size();
i++)
1032 for (
int i=0;
i<y.
size();
i++)
1041 for (
int i=0;
i<x.
size();
i++)
1043 for (
int i=0;
i<y.
size();
i++)
1052 for (
int i=0;
i<x.
size();
i++)
1054 for (
int i=0;
i<y.
size();
i++)
1063 for (
int i=0;
i<x.
size();
i++)
1074 for (
int i=0;
i<y.
size();
i++)
1084 template<
class View>
1088 template<
class View>
1092 x = (
n>0) ? home.
alloc<View>(
n) :
nullptr;
1094 template<
class View>
1098 x = (
n>0) ? r.
alloc<View>(
n) :
nullptr;
1101 template<
class View>
1106 for (
int i=0;
i<
n;
i++)
1112 template<
class View>
1117 for (
int i=0;
i<
n;
i++)
1124 template<
class View>
1129 template<
class View>
1136 template<
class View>
1142 template<
class View>
1148 template<
class View>
1151 assert((i >= 0) && (i <
size()));
1155 template<
class View>
1158 assert((i >= 0) && (i <
size()));
1162 template<
class View>
1168 template<
class View>
1174 template<
class View>
1180 template<
class View>
1186 template<
class View>
1192 template<
class View>
1198 template<
class View>
1204 template<
class View>
1210 template<
class View>
1213 x[
i]=x[0]; x++;
n--;
1216 template<
class View>
1222 template<
class View>
1229 template<
class View>
1236 template<
class View>
1241 x[
i]=x[0]; x++;
n--;
1244 template<
class View>
1252 template<
class View>
1257 for (
int j=0; j<
i; j++)
1262 template<
class View>
1267 for (
int j=i+1; j<
n; j++)
1272 template<
class View>
1277 x[
i]=x[0]; x++;
n--;
1280 template<
class View>
1288 template<
class View>
1293 for (
int j=0; j<
i; j++)
1298 template<
class View>
1303 for (
int j=i+1; j<
n; j++)
1308 template<
class View>
1314 for (
int i=0;
i<
n;
i++)
1321 template<
class View>
1325 for (
int i=0;
i<
n;
i++)
1329 template<
class View>
1332 for (
int i=0;
i<
n;
i++)
1336 template<
class View>
1339 for (
int i=0;
i<
n;
i++)
1343 template<
class View>
1346 for (
int i=0;
i<
n;
i++)
1350 template<
class View>
1353 for (
int i=0;
i<
n;
i++)
1357 template<
class View>
1360 for (
int i=0;
i<
n;
i++)
1366 template<
class View>
1372 View* y = r.
alloc<View>(
n);
1374 for (
int i=0;
i<
n;
i++)
1379 Support::quicksort<View>(
y,j);
1380 for (
int i=1;
i<j;
i++)
1386 template<
class View>
1391 for (
int i=0;
i<
n;
i++)
1397 template<
class View>
1402 Support::quicksort<View>(
x,
n);
1404 for (
int i=1;
i<
n;
i++)
1410 template<
class View>
1416 template<
class View>
1426 template<
class ViewX,
class ViewY>
1429 if ((x.
size() == 0) || (y.
size() == 0))
1434 for (
int i=0;
i<x.
size();
i++)
1436 px[j++] = x[
i].varimp();
1441 for (
int i=0;
i<y.
size();
i++)
1443 py[k++] = y[
i].varimp();
1449 template<
class ViewX,
class ViewY>
1452 if (y.assigned() || !y.varimp())
1454 for (
int i=0;
i<x.
size();
i++)
1455 if (!x[
i].
assigned() && x[
i].varimp() && (x[
i].varimp() == y.varimp()))
1460 template<
class ViewX,
class ViewY>
1466 template<
class View>
1474 for (
int i=0;
i<x.
size();
i++)
1476 px[j++] = x[
i].varimp();
1490 return (n > onstack_size) ?
1491 heap.
alloc<T>(
static_cast<unsigned int>(
n)) : &onstack[0];
1498 assert(
n+i >= onstack_size);
1500 if (newCapacity <=
n+i)
1502 T* newA = allocate(newCapacity);
1514 :
n(0),
capacity(onstack_size),
a(allocate(0)) {}
1519 :
n(n0),
capacity(
n < onstack_size ? onstack_size :
n),
a(allocate(
n)) {}
1524 :
n(aa.
n),
capacity(
n < onstack_size ? onstack_size :
n),
a(allocate(
n)) {
1531 :
n(static_cast<int>(aa.
size())),
1532 capacity(
n < onstack_size ? onstack_size :
n),
a(allocate(
n)) {
1539 :
n(static_cast<int>(aa.
size())),
1540 capacity(
n < onstack_size ? onstack_size :
n),
a(allocate(
n)) {
1542 for (
const T& x : aa)
1560 capacity = (
n < onstack_size ? onstack_size :
n);
1576 assert((i>=0) && (i <
n));
1583 assert((i>=0) && (i <
n));
1635 template<
class T>
template<
class A>
1638 assert(
n==0 || start <
n);
1645 s = (
n-start)/inc + ((
n-start) % inc == 0 ? 0 : 1);
1647 s = (start+1)/-inc + ((start+1) % -inc == 0 ? 0 : 1);
1649 for (
int i=0;
i<r.
size();
i++, start+=inc)
1650 new (&r[
i]) T(
a[start]);
1654 template<
class T>
template<
class A>
1659 return static_cast<A&
>(*this);
1663 template<
class InputIterator>
1666 :
n(0),
capacity(onstack_size),
a(allocate(0)) {
1667 while (first != last) {
1674 template<
class T>
template<
class A>
1678 for (
int i=0;
i<x.
size();
i++)
1679 new (&
a[
n++]) T(x[
i]);
1680 return static_cast<A&
>(*this);
1683 template<
class T>
template<
class A>
1687 for (
int i=0;
i<
n;
i++)
1688 new (&r[
i]) T(
a[i]);
1689 for (
int i=0; i<x.
n; i++)
1690 new (&r[n+i]) T(x.
a[i]);
1694 template<
class T>
template<
class A>
1698 for (
int i=0;
i<
n;
i++)
1699 new (&r[
i]) T(
a[i]);
1722 for (
int i=0;
i<
n;
i++)
1742 template<
class InputIterator>
1774 return x.template concat
1781 return x.template concat
1790 return xa.template concat
1823 template<
class InputIterator>
1832 for (
int i=0;
i<x.
size();
i++)
1863 return x.template concat
1870 return x.template concat
1879 return xa.template concat
1886 for (
int i=0;
i<
n;
i++)
1900 if ((x.
size() == 0) || (y.
size() == 0))
1905 for (
int i=0;
i<x.
size();
i++)
1907 px[j++] = x[
i].varimp();
1912 for (
int i=0;
i<y.
size();
i++)
1914 py[k++] = y[
i].varimp();
1925 for (
int i=0;
i<x.
size();
i++)
1926 if (x[
i].varimp() == y.varimp())
1945 for (
int i=0;
i<x.
size();
i++)
1947 px[j++] = x[
i].varimp();
1964 for (
int i=0;
i<
n;
i++)
1976 template<
class Char,
class Traits,
class Var>
1977 std::basic_ostream<Char,Traits>&
1978 operator <<(std::basic_ostream<Char,Traits>& os,
1980 std::basic_ostringstream<Char,Traits> s;
1981 s.copyfmt(os); s.width(0);
1985 for (
int i=1;
i<x.
size();
i++)
1989 return os << s.str();
1992 template<
class Char,
class Traits,
class View>
1993 std::basic_ostream<Char,Traits>&
1994 operator <<(std::basic_ostream<Char,Traits>& os,
1996 std::basic_ostringstream<Char,Traits> s;
1997 s.copyfmt(os); s.width(0);
2001 for (
int i=1;
i<x.
size();
i++)
2005 return os << s.str();
2008 template<
class Char,
class Traits,
class T>
2009 std::basic_ostream<Char,Traits>&
2010 operator <<(std::basic_ostream<Char,Traits>& os,
2012 std::basic_ostringstream<Char,Traits> s;
2013 s.copyfmt(os); s.width(0);
2017 for (
int i=1;
i<x.
size();
i++)
2021 return os << s.str();
int capacity
Allocated size of the array.
static T * copy(T *d, const T *s, long unsigned int n)
Copy n objects starting at s to d.
const T * const_iterator
Type of the iterator used to iterate read-only through this array's elements.
int size(void) const
Return size of array (number of elements)
int size(void) const
Return size of array (number of elements)
void cancel(Space &home, Propagator &p, IntSet &y)
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
Var * iterator
Type of the iterator used to iterate through this array's elements.
std::reverse_iterator< const T * > const_reverse_iterator
Type of the iterator used to iterate backwards and read-only through this array's elements...
Var & reference
Type of a reference to the value type.
Base-class for propagators.
Var * pointer
Type of a pointer to the value type.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const ArgArrayBase< T > &x)
T * iterator
Type of the iterator used to iterate through this array's elements.
const View & const_reference
Type of a constant reference to the value type.
View * iterator
Type of the iterator used to iterate through this array's elements.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
View * pointer
Type of a pointer to the value type.
const Var & const_reference
Type of a constant reference to the value type.
int p
Number of positive literals for node type.
std::reverse_iterator< const Var * > const_reverse_iterator
Type of the iterator used to iterate backwards and read-only through this array's elements...
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
const FloatNum min
Smallest allowed float value.
int n
Number of negative literals for node type.
Argument array for non-primitive types.
Gecode::IntArgs i({1, 2, 3, 4})
Var * x
Array of variables.
const View * const_pointer
Type of a read-only pointer to the value type.
FloatVal operator+(const FloatVal &x)
int PropCond
Type for propagation conditions.
void subscribe(Space &home, Propagator &p, IntSet &y)
ArrayTraits< VarArgArray< Var > >::ArgsType operator+(const Var &x, const VarArgArray< Var > &y)
bool same(VarArgArray< Var > x)
unsigned int size(I &i)
Size of all ranges of range iterator i.
ViewArray(Region &r, const VarArgArray< Var > &a)
Initialize from variable argument array a (copy elements)
VarArray(void)
Default constructor (array of size 0)
T & reference
Type of a reference to the value type.
bool duplicates(void **p, int n)
Check whether p has duplicates among its n elements (changes p)
#define GECODE_KERNEL_EXPORT
int n
Number of variables (size)
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc to all views.
bool shared(ViewArray< View > x)
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
Boolean integer variables.
Post propagator for SetVar SetOpType SetVar SetRelType r
T * pointer
Type of a pointer to the value type.
Post propagator for SetVar SetOpType SetVar y
View & reference
Type of a reference to the value type.
Base class for variables.
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Node * x
Pointer to corresponding Boolean expression node.
Base-class for argument arrays.
Heap heap
The single global heap.
bool assigned(View x, int v)
Whether x is assigned to value v.
const Var * const_pointer
Type of a read-only pointer to the value type.
Post propagator for SetVar x
Archive & operator<<(Archive &e, FloatNumBranch nl)
Traits of arrays in Gecode.
const T & const_reference
Type of a constant reference to the value type.
Gecode toplevel namespace
Argument array for variables.
const int capacity[n_warehouses]
Capacity of a single warehouse.
std::reverse_iterator< const View * > const_reverse_iterator
Type of the iterator used to iterate backwards and read-only through this array's elements...
ViewArray(Space &home, const VarArgArray< Var > &a)
Initialize from variable argument array a (copy elements)
std::reverse_iterator< T * > reverse_iterator
Type of the iterator used to iterate backwards through this array's elements.
bool shared(ViewArray< ViewX > x, ViewArray< ViewY > y)
void reschedule(Space &home, Propagator &p, IntSet &y)
const Var * const_iterator
Type of the iterator used to iterate read-only through this array's elements.
View value_type
Type of the view stored in this array.
int size(void) const
Return size of array (number of elements)
const View * const_iterator
Type of the iterator used to iterate read-only through this array's elements.
std::reverse_iterator< View * > reverse_iterator
Type of the iterator used to iterate backwards through this array's elements.
const T * const_pointer
Type of a read-only pointer to the value type.
void update(IntSet &y, Space &home, IntSet &py)
const unsigned int slice
Size of a slice in a portfolio and scale factor for restarts(in number of failures) ...
struct Gecode::@593::NNF::@62::@64 a
For atomic nodes.
std::reverse_iterator< Var * > reverse_iterator
Type of the iterator used to iterate backwards through this array's elements.