Generated on Fri Jan 28 2022 04:43:06 for Gecode by doxygen 1.8.13
array.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  * Guido Tack <tack@gecode.org>
6  *
7  * Contributing authors:
8  * Gregory Crosswhite <gcross@phys.washington.edu>
9  *
10  * Copyright:
11  * Gregory Crosswhite, 2011
12  * Christian Schulte, 2003
13  * Guido Tack, 2004
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #include <iostream>
41 #include <iterator>
42 #include <vector>
43 #include <sstream>
44 #include <initializer_list>
45 
46 namespace Gecode { namespace Kernel {
47 
50  bool duplicates(void** p, int n);
51 
54  bool duplicates(void** p, int n, void** q, int m);
55 
56 }}
57 
58 namespace Gecode {
59 
60  template<class Var> class VarArray;
61  template<class Var> class VarArgArray;
62 
75  template<class A>
76  class ArrayTraits {};
77 
93  template<class Var>
94  class VarArray {
95  protected:
97  int n;
99  Var* x;
100  public:
102 
103  typedef Var value_type;
106  typedef Var& reference;
108  typedef const Var& const_reference;
110  typedef Var* pointer;
112  typedef const Var* const_pointer;
114  typedef Var* iterator;
116  typedef const Var* const_iterator;
118  typedef std::reverse_iterator<Var*> reverse_iterator;
120  typedef std::reverse_iterator<const Var*> const_reverse_iterator;
122 
124 
126  VarArray(void);
129  VarArray(Space& home, int m);
131  VarArray(Space& home, const VarArgArray<Var>&);
133  VarArray(const VarArray<Var>& a);
135  const VarArray<Var>& operator =(const VarArray<Var>& a);
137 
139 
140  int size(void) const;
143 
145 
146  Var& operator [](int i);
149  const Var& operator [](int i) const;
155  typename ArrayTraits<VarArgArray<Var>>::ArgsType
156  slice(int start, int inc=1, int n=-1);
158 
160 
161  iterator begin(void);
164  const_iterator begin(void) const;
166  iterator end(void);
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;
178 
180  bool assigned(void) const;
181 
183 
184  void update(Space& home, VarArray<Var>& a);
187  private:
188  static void* operator new(size_t) throw();
189  static void operator delete(void*,size_t);
190  };
191 
195  template<class T>
196  typename ArrayTraits<VarArray<T>>::ArgsType
197  operator +(const VarArray<T>& x, const VarArgArray<T>& y);
198 
202  template<class T>
203  typename ArrayTraits<VarArray<T>>::ArgsType
204  operator +(const VarArray<T>& x, const VarArray<T>& y);
205 
209  template<class T>
210  typename ArrayTraits<VarArray<T>>::ArgsType
211  operator +(const VarArgArray<T>& x, const VarArray<T>& y);
212 
216  template<class T>
217  typename ArrayTraits<VarArray<T>>::ArgsType
218  operator +(const VarArray<T>& x, const T& y);
219 
223  template<class T>
224  typename ArrayTraits<VarArray<T>>::ArgsType
225  operator +(const T& x, const VarArray<T>& y);
226 
234  template<class View>
235  class ViewArray {
236  private:
238  int n;
240  View* x;
241  public:
243 
244  typedef View value_type;
247  typedef View& reference;
249  typedef const View& const_reference;
251  typedef View* pointer;
253  typedef const View* const_pointer;
255  typedef View* iterator;
257  typedef const View* const_iterator;
259  typedef std::reverse_iterator<View*> reverse_iterator;
261  typedef std::reverse_iterator<const View*> const_reverse_iterator;
263 
265 
266  ViewArray(void);
269  ViewArray(Space& home, int m);
271  ViewArray(Region& r, int m);
273  ViewArray(const ViewArray<View>& a);
275  ViewArray(Space& home, const ViewArray<View>& a);
277  ViewArray(Region& r, const ViewArray<View>& a);
279  const ViewArray<View>& operator =(const ViewArray<View>& a);
286  template<class Var>
288  : n(a.size()) {
289  // This may not be in the hpp file (to satisfy the MS compiler)
290  if (n>0) {
291  x = home.alloc<View>(n);
292  for (int i=0; i<n; i++)
293  x[i]=a[i];
294  } else {
295  x = nullptr;
296  }
297  }
304  template<class Var>
306  : n(a.size()) {
307  // This may not be in the hpp file (to satisfy the MS compiler)
308  if (n>0) {
309  x = r.alloc<View>(n);
310  for (int i=0; i<n; i++)
311  x[i]=a[i];
312  } else {
313  x = nullptr;
314  }
315  }
317 
319 
320  int size(void) const;
323  void size(int n);
325 
327 
328  View& operator [](int i);
331  const View& operator [](int i) const;
333 
335 
336  iterator begin(void);
339  const_iterator begin(void) const;
341  iterator end(void);
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;
353 
355 
356 
363  void subscribe(Space& home, Propagator& p, PropCond pc,
364  bool schedule=true);
366  void cancel(Space& home, Propagator& p, PropCond pc);
368  void subscribe(Space& home, Advisor& a);
370  void cancel(Space& home, Advisor& a);
372  void reschedule(Space& home, Propagator& p, PropCond pc);
374 
376 
377  void update(Space& home, ViewArray<View>& a);
380 
381 
383 
384  void move_fst(int i);
387  void move_lst(int i);
393  void move_fst(int i, Space& home, Propagator& p, PropCond pc);
399  void move_lst(int i, Space& home, Propagator& p, PropCond pc);
405  void move_fst(int i, Space& home, Advisor& a);
411  void move_lst(int i, Space& home, Advisor& a);
413 
415 
416  void drop_fst(int i);
419  void drop_lst(int i);
425  void drop_fst(int i, Space& home, Propagator& p, PropCond pc);
432  void drop_lst(int i, Space& home, Propagator& p, PropCond pc);
438  void drop_fst(int i, Space& home, Advisor& a);
444  void drop_lst(int i, Space& home, Advisor& a);
446 
448  bool assigned(void) const;
449 
451 
452 
457  bool same(void) const;
463  bool same(const View& y) const;
465  void unique(void);
467  private:
468  static void* operator new(size_t) throw();
469  static void operator delete(void*,size_t);
470  };
471 
472 
479  template<class ViewX, class ViewY>
487  template<class ViewX, class ViewY>
488  bool shared(ViewArray<ViewX> x, ViewY y);
495  template<class ViewX, class ViewY>
496  bool shared(ViewX x, ViewArray<ViewY> y);
503  template<class View>
504  bool shared(ViewArray<View> x);
505 
506 
518  template<class T>
519  class ArgArrayBase {
520  protected:
522  int n;
524  int capacity;
526  T* a;
528  static const int onstack_size = 16;
530  T onstack[onstack_size];
532  T* allocate(int n);
534  void resize(int i);
536  template<class A>
537  A concat(const ArgArrayBase<T>& x) const;
539  template<class A>
540  A concat(const T& x) const;
542  template<class A>
543  A& append(const T& x);
545  template<class A>
546  A& append(const ArgArrayBase<T>& x);
552  template<class A>
553  A slice(int start, int inc=1, int n=-1);
554  public:
556 
557  typedef T value_type;
560  typedef T& reference;
562  typedef const T& const_reference;
564  typedef T* pointer;
566  typedef const T* const_pointer;
568  typedef T* iterator;
570  typedef const T* const_iterator;
572  typedef std::reverse_iterator<T*> reverse_iterator;
574  typedef std::reverse_iterator<const T*> const_reverse_iterator;
576 
578 
579  ArgArrayBase(void);
582  explicit ArgArrayBase(int n);
584  ArgArrayBase(const ArgArrayBase<T>& a);
586  const ArgArrayBase<T>& operator =(const ArgArrayBase<T>& a);
588  ArgArrayBase(const std::vector<T>& a);
590  ArgArrayBase(std::initializer_list<T> a);
592  template<class InputIterator>
593  ArgArrayBase(InputIterator first, InputIterator last);
595 
597 
598  int size(void) const;
601 
603 
604  T& operator [](int i);
607  const T& operator [](int i) const;
609 
611 
612  iterator begin(void);
615  const_iterator begin(void) const;
617  iterator end(void);
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;
629 
631 
632  ~ArgArrayBase(void);
635  };
636 
637 
638  template<class> class ArgArray;
639 
643  template<class T>
644  typename ArrayTraits<ArgArray<T>>::ArgsType
645  operator +(const ArgArray<T>& x, const ArgArray<T>& y);
646 
650  template<class T>
651  typename ArrayTraits<ArgArray<T>>::ArgsType
652  operator +(const ArgArray<T>& x, const T& y);
653 
657  template<class T>
658  typename ArrayTraits<ArgArray<T>>::ArgsType
659  operator +(const T& x, const ArgArray<T>& y);
660 
672  template<class T>
673  class ArgArray : public ArgArrayBase<T> {
674  protected:
675  using ArgArrayBase<T>::a;
676  public:
677  using ArgArrayBase<T>::size;
679 
680  ArgArray(void);
683  explicit ArgArray(int n);
685  ArgArray(int n, const T* e);
687  ArgArray(const ArgArray<T>& a);
689  ArgArray(const std::vector<T>& a);
691  ArgArray(std::initializer_list<T> a);
693  template<class InputIterator>
694  ArgArray(InputIterator first, InputIterator last);
696 
698  typename ArrayTraits<ArgArray<T>>::ArgsType
700  slice(int start, int inc=1, int n=-1);
702 
704  typename ArrayTraits<ArgArray<T>>::ArgsType&
706  operator <<(const T& x);
708  typename ArrayTraits<ArgArray<T>>::ArgsType&
709  operator <<(const ArgArray<T>& x);
711 
712  friend typename ArrayTraits<ArgArray<T>>::ArgsType
713  operator + <>(const ArgArray<T>& x, const ArgArray<T>& y);
714  friend typename ArrayTraits<ArgArray<T>>::ArgsType
715  operator + <>(const ArgArray<T>& x, const T& y);
716  friend
717  typename ArrayTraits<ArgArray<T>>::ArgsType
718  operator + <>(const T& x, const ArgArray<T>& y);
719  };
720 
721  template<class> class VarArgArray;
722 
726  template<class Var>
727  typename ArrayTraits<VarArgArray<Var>>::ArgsType
728  operator +(const VarArgArray<Var>& x, const VarArgArray<Var>& y);
729 
733  template<class Var>
734  typename ArrayTraits<VarArgArray<Var>>::ArgsType
735  operator +(const VarArgArray<Var>& x, const Var& y);
736 
740  template<class Var>
741  typename ArrayTraits<VarArgArray<Var>>::ArgsType
742  operator +(const Var& x, const VarArgArray<Var>& y);
743 
755  template<class Var>
756  class VarArgArray : public ArgArrayBase<Var> {
757  protected:
758  using ArgArrayBase<Var>::a;
759  using ArgArrayBase<Var>::n;
760  public:
763 
764  VarArgArray(void);
767  explicit VarArgArray(int n);
771  VarArgArray(const VarArray<Var>& a);
773  VarArgArray(const std::vector<Var>& a);
775  VarArgArray(std::initializer_list<Var> a);
777  template<class InputIterator>
778  VarArgArray(InputIterator first, InputIterator last);
780 
782  typename ArrayTraits<VarArgArray<Var>>::ArgsType
784  slice(int start, int inc=1, int n=-1);
786 
788  typename ArrayTraits<VarArgArray<Var>>::ArgsType&
790  operator <<(const Var& x);
792  typename ArrayTraits<VarArgArray<Var>>::ArgsType&
793  operator <<(const VarArgArray<Var>& x);
795 
797  bool assigned(void) const;
798 
799  friend typename ArrayTraits<VarArgArray<Var>>::ArgsType
800  operator + <>(const VarArgArray<Var>& x, const VarArgArray<Var>& y);
801  friend typename ArrayTraits<VarArgArray<Var>>::ArgsType
802  operator + <>(const VarArgArray<Var>& x, const Var& y);
803  friend
804  typename ArrayTraits<VarArgArray<Var>>::ArgsType
805  operator + <>(const Var& x, const VarArgArray<Var>& y);
806  };
807 
808 
815  template<class Var>
823  template<class Var>
824  bool same(VarArgArray<Var> x, Var y);
831  template<class Var>
832  bool same(Var x, VarArgArray<Var> y);
839  template<class Var>
840  bool same(VarArgArray<Var> x);
841 
842 
847  template<class Char, class Traits, class Var>
848  std::basic_ostream<Char,Traits>&
849  operator <<(std::basic_ostream<Char,Traits>& os,
850  const VarArray<Var>& x);
851 
856  template<class Char, class Traits, class View>
857  std::basic_ostream<Char,Traits>&
858  operator <<(std::basic_ostream<Char,Traits>& os, const ViewArray<View>& x);
859 
864  template<class Char, class Traits, class T>
865  std::basic_ostream<Char,Traits>&
866  operator <<(std::basic_ostream<Char,Traits>& os, const ArgArrayBase<T>& x);
867 
868 
869  /*
870  * Implementation
871  *
872  */
873 
874  /*
875  * Variable arrays
876  *
877  * These arrays are allocated in the space.
878  *
879  */
880 
881  template<class Var>
883  VarArray<Var>::VarArray(void) : n(0), x(nullptr) {}
884 
885  template<class Var>
888  : n(n0) {
889  // Allocate from space
890  x = (n>0) ? home.alloc<Var>(n) : nullptr;
891  }
892 
893  template<class Var>
896  n = a.n; x = a.x;
897  }
898 
899  template<class Var>
900  inline const VarArray<Var>&
902  n = a.n; x = a.x;
903  return *this;
904  }
905 
906  template<class Var>
907  forceinline int
908  VarArray<Var>::size(void) const {
909  return n;
910  }
911 
912  template<class Var>
915  assert((i >= 0) && (i < size()));
916  return x[i];
917  }
918 
919  template<class Var>
920  forceinline const Var&
922  assert((i >= 0) && (i < size()));
923  return x[i];
924  }
925 
926  template<class Var>
927  typename ArrayTraits<VarArgArray<Var>>::ArgsType
928  VarArray<Var>::slice(int start, int inc, int maxN) {
929  assert(n==0 || start < n);
930  if (n==0 || maxN<0)
931  maxN = n;
932  int s;
933  if (inc == 0)
934  s = n-start;
935  else if (inc > 0)
936  s = (n-start)/inc + ((n-start) % inc == 0 ? 0 : 1);
937  else
938  s = (start+1)/-inc + ((start+1) % -inc == 0 ? 0 : 1);
939  typename ArrayTraits<VarArgArray<Var>>::ArgsType r(std::min(maxN,s));
940  for (int i=0; i<r.size(); i++, start+=inc)
941  r[i] = x[start];
942  return r;
943  }
944 
945  template<class Var>
948  return x;
949  }
950 
951  template<class Var>
953  VarArray<Var>::begin(void) const {
954  return x;
955  }
956 
957  template<class Var>
960  return x+n;
961  }
962 
963  template<class Var>
965  VarArray<Var>::end(void) const {
966  return x+n;
967  }
968 
969  template<class Var>
972  return reverse_iterator(x+n);
973  }
974 
975  template<class Var>
977  VarArray<Var>::rbegin(void) const {
978  return const_reverse_iterator(x+n);
979  }
980 
981  template<class Var>
984  return reverse_iterator(x);
985  }
986 
987  template<class Var>
989  VarArray<Var>::rend(void) const {
990  return const_reverse_iterator(x);
991  }
992 
993  template<class Var>
994  forceinline void
996  n = a.n;
997  if (n > 0) {
998  x = home.alloc<Var>(n);
999  for (int i=0; i<n; i++)
1000  x[i].update(home, a.x[i]);
1001  } else {
1002  x = nullptr;
1003  }
1004  }
1005 
1006  template<class Var>
1007  forceinline bool
1009  for (int i=0; i<n; i++)
1010  if (!x[i].assigned())
1011  return false;
1012  return true;
1013  }
1014 
1015  template<class Var>
1016  forceinline void*
1017  VarArray<Var>::operator new(size_t) throw() {
1018  return nullptr;
1019  }
1020 
1021  template<class Var>
1022  forceinline void
1023  VarArray<Var>::operator delete(void*,size_t) {
1024  }
1025 
1026  template<class Var>
1027  typename ArrayTraits<VarArray<Var>>::ArgsType
1029  typename ArrayTraits<VarArray<Var>>::ArgsType r(x.size()+y.size());
1030  for (int i=0; i<x.size(); i++)
1031  r[i] = x[i];
1032  for (int i=0; i<y.size(); i++)
1033  r[x.size()+i] = y[i];
1034  return r;
1035  }
1036 
1037  template<class Var>
1038  typename ArrayTraits<VarArray<Var>>::ArgsType
1040  typename ArrayTraits<VarArray<Var>>::ArgsType r(x.size()+y.size());
1041  for (int i=0; i<x.size(); i++)
1042  r[i] = x[i];
1043  for (int i=0; i<y.size(); i++)
1044  r[x.size()+i] = y[i];
1045  return r;
1046  }
1047 
1048  template<class Var>
1049  typename ArrayTraits<VarArray<Var>>::ArgsType
1051  typename ArrayTraits<VarArray<Var>>::ArgsType r(x.size()+y.size());
1052  for (int i=0; i<x.size(); i++)
1053  r[i] = x[i];
1054  for (int i=0; i<y.size(); i++)
1055  r[x.size()+i] = y[i];
1056  return r;
1057  }
1058 
1059  template<class Var>
1060  typename ArrayTraits<VarArray<Var>>::ArgsType
1061  operator +(const VarArray<Var>& x, const Var& y) {
1062  typename ArrayTraits<VarArray<Var>>::ArgsType r(x.size()+1);
1063  for (int i=0; i<x.size(); i++)
1064  r[i] = x[i];
1065  r[x.size()] = y;
1066  return r;
1067  }
1068 
1069  template<class Var>
1070  typename ArrayTraits<VarArray<Var>>::ArgsType
1071  operator +(const Var& x, const VarArray<Var>& y) {
1072  typename ArrayTraits<VarArray<Var>>::ArgsType r(y.size()+1);
1073  r[0] = x;
1074  for (int i=0; i<y.size(); i++)
1075  r[1+i] = y[i];
1076  return r;
1077  }
1078 
1079  /*
1080  * View arrays
1081  *
1082  */
1083 
1084  template<class View>
1085  forceinline
1086  ViewArray<View>::ViewArray(void) : n(0), x(nullptr) {}
1087 
1088  template<class View>
1089  forceinline
1091  : n(n0) {
1092  x = (n>0) ? home.alloc<View>(n) : nullptr;
1093  }
1094  template<class View>
1095  forceinline
1097  : n(n0) {
1098  x = (n>0) ? r.alloc<View>(n) : nullptr;
1099  }
1100 
1101  template<class View>
1103  : n(a.size()) {
1104  if (n>0) {
1105  x = home.alloc<View>(n);
1106  for (int i=0; i<n; i++)
1107  x[i] = a[i];
1108  } else {
1109  x = nullptr;
1110  }
1111  }
1112  template<class View>
1114  : n(a.size()) {
1115  if (n>0) {
1116  x = r.alloc<View>(n);
1117  for (int i=0; i<n; i++)
1118  x[i] = a[i];
1119  } else {
1120  x = nullptr;
1121  }
1122  }
1123 
1124  template<class View>
1125  forceinline
1127  : n(a.n), x(a.x) {}
1128 
1129  template<class View>
1132  n = a.n; x = a.x;
1133  return *this;
1134  }
1135 
1136  template<class View>
1137  forceinline int
1139  return n;
1140  }
1141 
1142  template<class View>
1143  forceinline void
1145  n = n0;
1146  }
1147 
1148  template<class View>
1149  forceinline View&
1151  assert((i >= 0) && (i < size()));
1152  return x[i];
1153  }
1154 
1155  template<class View>
1156  forceinline const View&
1158  assert((i >= 0) && (i < size()));
1159  return x[i];
1160  }
1161 
1162  template<class View>
1165  return x;
1166  }
1167 
1168  template<class View>
1171  return x;
1172  }
1173 
1174  template<class View>
1177  return x+n;
1178  }
1179 
1180  template<class View>
1182  ViewArray<View>::end(void) const {
1183  return x+n;
1184  }
1185 
1186  template<class View>
1189  return reverse_iterator(x+n);
1190  }
1191 
1192  template<class View>
1195  return const_reverse_iterator(x+n);
1196  }
1197 
1198  template<class View>
1201  return reverse_iterator(x);
1202  }
1203 
1204  template<class View>
1207  return const_reverse_iterator(x);
1208  }
1209 
1210  template<class View>
1211  forceinline void
1213  x[i]=x[0]; x++; n--;
1214  }
1215 
1216  template<class View>
1217  forceinline void
1219  n--; x[i]=x[n];
1220  }
1221 
1222  template<class View>
1223  forceinline void
1225  assert(i>=0);
1226  x += i; n -= i;
1227  }
1228 
1229  template<class View>
1230  forceinline void
1232  assert(i<n);
1233  n = i+1;
1234  }
1235 
1236  template<class View>
1237  forceinline void
1239  // Move x[0] to x[i]
1240  x[i].cancel(home,p,pc);
1241  x[i]=x[0]; x++; n--;
1242  }
1243 
1244  template<class View>
1245  forceinline void
1247  // Move x[n-1] to x[i]
1248  x[i].cancel(home,p,pc);
1249  n--; x[i]=x[n];
1250  }
1251 
1252  template<class View>
1253  void
1255  // Drop elements from 0..i-1
1256  assert(i>=0);
1257  for (int j=0; j<i; j++)
1258  x[j].cancel(home,p,pc);
1259  x += i; n -= i;
1260  }
1261 
1262  template<class View>
1263  void
1265  // Drop elements from i+1..n-1
1266  assert(i<n);
1267  for (int j=i+1; j<n; j++)
1268  x[j].cancel(home,p,pc);
1269  n = i+1;
1270  }
1271 
1272  template<class View>
1273  forceinline void
1275  // Move x[0] to x[i]
1276  x[i].cancel(home,a);
1277  x[i]=x[0]; x++; n--;
1278  }
1279 
1280  template<class View>
1281  forceinline void
1283  // Move x[n-1] to x[i]
1284  x[i].cancel(home,a);
1285  n--; x[i]=x[n];
1286  }
1287 
1288  template<class View>
1289  void
1291  // Drop elements from 0..i-1
1292  assert(i>=0);
1293  for (int j=0; j<i; j++)
1294  x[j].cancel(home,a);
1295  x += i; n -= i;
1296  }
1297 
1298  template<class View>
1299  void
1301  // Drop elements from i+1..n-1
1302  assert(i<n);
1303  for (int j=i+1; j<n; j++)
1304  x[j].cancel(home,a);
1305  n = i+1;
1306  }
1307 
1308  template<class View>
1309  void
1311  n = y.n;
1312  if (n > 0) {
1313  x = home.alloc<View>(n);
1314  for (int i=0; i<n; i++)
1315  x[i].update(home, y.x[i]);
1316  } else {
1317  x = nullptr;
1318  }
1319  }
1320 
1321  template<class View>
1322  void
1324  bool schedule) {
1325  for (int i=0; i<n; i++)
1326  x[i].subscribe(home,p,pc,schedule);
1327  }
1328 
1329  template<class View>
1330  void
1332  for (int i=0; i<n; i++)
1333  x[i].cancel(home,p,pc);
1334  }
1335 
1336  template<class View>
1337  void
1339  for (int i=0; i<n; i++)
1340  x[i].subscribe(home,a);
1341  }
1342 
1343  template<class View>
1344  void
1346  for (int i=0; i<n; i++)
1347  x[i].cancel(home,a);
1348  }
1349 
1350  template<class View>
1351  void
1353  for (int i=0; i<n; i++)
1354  x[i].reschedule(home,p,pc);
1355  }
1356 
1357  template<class View>
1358  forceinline bool
1360  for (int i=0; i<n; i++)
1361  if (!x[i].assigned())
1362  return false;
1363  return true;
1364  }
1365 
1366  template<class View>
1367  bool
1369  if (n < 2)
1370  return false;
1371  Region r;
1372  View* y = r.alloc<View>(n);
1373  int j=0;
1374  for (int i=0; i<n; i++)
1375  if (!x[i].assigned())
1376  y[j++] = x[i];
1377  if (j < 2)
1378  return false;
1379  Support::quicksort<View>(y,j);
1380  for (int i=1; i<j; i++)
1381  if (y[i-1] == y[i])
1382  return true;
1383  return false;
1384  }
1385 
1386  template<class View>
1387  bool
1388  ViewArray<View>::same(const View& y) const {
1389  if (y.assigned())
1390  return false;
1391  for (int i=0; i<n; i++)
1392  if (x[i] == y)
1393  return true;
1394  return false;
1395  }
1396 
1397  template<class View>
1398  void
1400  if (n < 2)
1401  return;
1402  Support::quicksort<View>(x,n);
1403  int j = 0;
1404  for (int i=1; i<n; i++)
1405  if (x[j] != x[i])
1406  x[++j] = x[i];
1407  n = j+1;
1408  }
1409 
1410  template<class View>
1411  forceinline void*
1412  ViewArray<View>::operator new(size_t) throw() {
1413  return nullptr;
1414  }
1415 
1416  template<class View>
1417  forceinline void
1418  ViewArray<View>::operator delete(void*,size_t) {
1419  }
1420 
1421 
1422  /*
1423  * Sharing for view arrays
1424  *
1425  */
1426  template<class ViewX, class ViewY>
1427  bool
1429  if ((x.size() == 0) || (y.size() == 0))
1430  return false;
1431  Region r;
1432  void** px = r.alloc<void*>(x.size());
1433  int j=0;
1434  for (int i=0; i<x.size(); i++)
1435  if (!x[i].assigned() && x[i].varimp())
1436  px[j++] = x[i].varimp();
1437  if (j == 0)
1438  return false;
1439  void** py = r.alloc<void*>(y.size());
1440  int k=0;
1441  for (int i=0; i<y.size(); i++)
1442  if (!y[i].assigned() && y[i].varimp())
1443  py[k++] = y[i].varimp();
1444  if (k == 0)
1445  return false;
1446  return Kernel::duplicates(px,j,py,k);
1447  }
1448 
1449  template<class ViewX, class ViewY>
1450  bool
1451  shared(ViewArray<ViewX> x, ViewY y) {
1452  if (y.assigned() || !y.varimp())
1453  return false;
1454  for (int i=0; i<x.size(); i++)
1455  if (!x[i].assigned() && x[i].varimp() && (x[i].varimp() == y.varimp()))
1456  return true;
1457  return false;
1458  }
1459 
1460  template<class ViewX, class ViewY>
1461  forceinline bool
1462  shared(ViewX x, ViewArray<ViewY> y) {
1463  return shared(y,x);
1464  }
1465 
1466  template<class View>
1467  bool
1469  if (x.size() < 2)
1470  return false;
1471  Region r;
1472  void** px = r.alloc<void*>(x.size());
1473  int j=0;
1474  for (int i=0; i<x.size(); i++)
1475  if (!x[i].assigned() && x[i].varimp())
1476  px[j++] = x[i].varimp();
1477  return (j > 2) && Kernel::duplicates(px,j);
1478  }
1479 
1480 
1481 
1482  /*
1483  * Argument arrays: base class
1484  *
1485  */
1486 
1487  template<class T>
1488  forceinline T*
1490  return (n > onstack_size) ?
1491  heap.alloc<T>(static_cast<unsigned int>(n)) : &onstack[0];
1492  }
1493 
1494  template<class T>
1495  forceinline void
1497  if (n+i >= capacity) {
1498  assert(n+i >= onstack_size);
1499  int newCapacity = (3*capacity)/2;
1500  if (newCapacity <= n+i)
1501  newCapacity = n+i;
1502  T* newA = allocate(newCapacity);
1503  heap.copy<T>(newA,a,n);
1504  if (capacity > onstack_size)
1505  heap.free(a,capacity);
1506  capacity = newCapacity;
1507  a = newA;
1508  }
1509  }
1510 
1511  template<class T>
1512  forceinline
1514  : n(0), capacity(onstack_size), a(allocate(0)) {}
1515 
1516  template<class T>
1517  forceinline
1519  : n(n0), capacity(n < onstack_size ? onstack_size : n), a(allocate(n)) {}
1520 
1521  template<class T>
1522  inline
1524  : n(aa.n), capacity(n < onstack_size ? onstack_size : n), a(allocate(n)) {
1525  heap.copy<T>(a,aa.a,n);
1526  }
1527 
1528  template<class T>
1529  inline
1530  ArgArrayBase<T>::ArgArrayBase(const std::vector<T>& aa)
1531  : n(static_cast<int>(aa.size())),
1532  capacity(n < onstack_size ? onstack_size : n), a(allocate(n)) {
1533  heap.copy<T>(a,&aa[0],n);
1534  }
1535 
1536  template<class T>
1537  inline
1538  ArgArrayBase<T>::ArgArrayBase(std::initializer_list<T> aa)
1539  : n(static_cast<int>(aa.size())),
1540  capacity(n < onstack_size ? onstack_size : n), a(allocate(n)) {
1541  int i=0;
1542  for (const T& x : aa)
1543  a[i++]=x;
1544  }
1545 
1546  template<class T>
1547  forceinline
1549  if (capacity > onstack_size)
1550  heap.free(a,capacity);
1551  }
1552 
1553  template<class T>
1556  if (&aa != this) {
1557  if (capacity > onstack_size)
1558  heap.free(a,capacity);
1559  n = aa.n;
1560  capacity = (n < onstack_size ? onstack_size : n);
1561  a = allocate(aa.n);
1562  heap.copy<T>(a,aa.a,n);
1563  }
1564  return *this;
1565  }
1566 
1567  template<class T>
1568  forceinline int
1570  return n;
1571  }
1572 
1573  template<class T>
1574  forceinline T&
1576  assert((i>=0) && (i < n));
1577  return a[i];
1578  }
1579 
1580  template<class T>
1581  forceinline const T&
1583  assert((i>=0) && (i < n));
1584  return a[i];
1585  }
1586 
1587  template<class T>
1590  return a;
1591  }
1592 
1593  template<class T>
1596  return a;
1597  }
1598 
1599  template<class T>
1602  return a+n;
1603  }
1604 
1605  template<class T>
1607  ArgArrayBase<T>::end(void) const {
1608  return a+n;
1609  }
1610 
1611  template<class T>
1614  return reverse_iterator(a+n);
1615  }
1616 
1617  template<class T>
1620  return const_reverse_iterator(a+n);
1621  }
1622 
1623  template<class T>
1626  return reverse_iterator(a);
1627  }
1628 
1629  template<class T>
1632  return const_reverse_iterator(a);
1633  }
1634 
1635  template<class T> template<class A>
1636  A
1637  ArgArrayBase<T>::slice(int start, int inc, int maxN) {
1638  assert(n==0 || start < n);
1639  if (n==0 || maxN<0)
1640  maxN = n;
1641  int s;
1642  if (inc == 0)
1643  s = n-start;
1644  else if (inc > 0)
1645  s = (n-start)/inc + ((n-start) % inc == 0 ? 0 : 1);
1646  else
1647  s = (start+1)/-inc + ((start+1) % -inc == 0 ? 0 : 1);
1648  A r(std::min(maxN,s));
1649  for (int i=0; i<r.size(); i++, start+=inc)
1650  new (&r[i]) T(a[start]);
1651  return r;
1652  }
1653 
1654  template<class T> template<class A>
1655  inline A&
1657  resize(1);
1658  new (&a[n++]) T(x);
1659  return static_cast<A&>(*this);
1660  }
1661 
1662  template<class T>
1663  template<class InputIterator>
1664  inline
1665  ArgArrayBase<T>::ArgArrayBase(InputIterator first, InputIterator last)
1666  : n(0), capacity(onstack_size), a(allocate(0)) {
1667  while (first != last) {
1668  (void) append<ArgArrayBase<T>>(*first);
1669  ++first;
1670  }
1671  }
1672 
1673 
1674  template<class T> template<class A>
1675  inline A&
1677  resize(x.size());
1678  for (int i=0; i<x.size(); i++)
1679  new (&a[n++]) T(x[i]);
1680  return static_cast<A&>(*this);
1681  }
1682 
1683  template<class T> template<class A>
1684  inline A
1686  A r(n+x.n);
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]);
1691  return r;
1692  }
1693 
1694  template<class T> template<class A>
1695  inline A
1696  ArgArrayBase<T>::concat(const T& x) const {
1697  A r(n+1);
1698  for (int i=0; i<n; i++)
1699  new (&r[i]) T(a[i]);
1700  new (&r[n]) T(x);
1701  return r;
1702  }
1703 
1704 
1705  /*
1706  * Argument arrays
1707  *
1708  */
1709 
1710  template<class T>
1711  forceinline
1713 
1714  template<class T>
1715  forceinline
1717  : ArgArrayBase<T>(n) {}
1718 
1719  template<class T>
1720  ArgArray<T>::ArgArray(int n, const T* a0)
1721  : ArgArrayBase<T>(n) {
1722  for (int i=0; i<n; i++)
1723  a[i] = a0[i];
1724  }
1725 
1726  template<class T>
1727  forceinline
1729  : ArgArrayBase<T>(aa) {}
1730 
1731  template<class T>
1732  forceinline
1733  ArgArray<T>::ArgArray(const std::vector<T>& aa)
1734  : ArgArrayBase<T>(aa) {}
1735 
1736  template<class T>
1737  forceinline
1738  ArgArray<T>::ArgArray(std::initializer_list<T> aa)
1739  : ArgArrayBase<T>(aa) {}
1740 
1741  template<class T>
1742  template<class InputIterator>
1743  forceinline
1744  ArgArray<T>::ArgArray(InputIterator first, InputIterator last)
1745  : ArgArrayBase<T>(first,last) {}
1746 
1747  template<class T>
1748  forceinline typename ArrayTraits<ArgArray<T>>::ArgsType
1749  ArgArray<T>::slice(int start, int inc, int maxN) {
1751  <typename ArrayTraits<ArgArray<T>>::ArgsType>
1752  (start,inc,maxN);
1753  }
1754 
1755  template<class T>
1756  forceinline typename ArrayTraits<ArgArray<T>>::ArgsType&
1758  return
1760  <typename ArrayTraits<ArgArray<T>>::ArgsType>(x);
1761  }
1762 
1763  template<class T>
1764  forceinline typename ArrayTraits<ArgArray<T>>::ArgsType&
1766  return
1768  <typename ArrayTraits<ArgArray<T>>::ArgsType>(x);
1769  }
1770 
1771  template<class T>
1772  typename ArrayTraits<ArgArray<T>>::ArgsType
1773  operator +(const ArgArray<T>& x, const ArgArray<T>& y) {
1774  return x.template concat
1775  <typename ArrayTraits<ArgArray<T>>::ArgsType>(y);
1776  }
1777 
1778  template<class T>
1779  typename ArrayTraits<ArgArray<T>>::ArgsType
1780  operator +(const ArgArray<T>& x, const T& y) {
1781  return x.template concat
1782  <typename ArrayTraits<ArgArray<T>>::ArgsType>(y);
1783  }
1784 
1785  template<class T>
1786  typename ArrayTraits<ArgArray<T>>::ArgsType
1787  operator +(const T& x, const ArgArray<T>& y) {
1788  ArgArray<T> xa(1);
1789  xa[0] = x;
1790  return xa.template concat
1791  <typename ArrayTraits<ArgArray<T>>::ArgsType>(y);
1792  }
1793 
1794  /*
1795  * Argument arrays for variables
1796  *
1797  */
1798 
1799  template<class Var>
1800  forceinline
1802 
1803  template<class Var>
1804  forceinline
1806 
1807  template<class Var>
1808  forceinline
1810  : ArgArrayBase<Var>(aa) {}
1811 
1812  template<class Var>
1813  forceinline
1814  VarArgArray<Var>::VarArgArray(const std::vector<Var>& aa)
1815  : ArgArrayBase<Var>(aa) {}
1816 
1817  template<class Var>
1818  forceinline
1819  VarArgArray<Var>::VarArgArray(std::initializer_list<Var> aa)
1820  : ArgArrayBase<Var>(aa) {}
1821 
1822  template<class Var>
1823  template<class InputIterator>
1824  forceinline
1825  VarArgArray<Var>::VarArgArray(InputIterator first, InputIterator last)
1826  : ArgArrayBase<Var>(first,last) {}
1827 
1828  template<class Var>
1829  inline
1831  : ArgArrayBase<Var>(x.size()) {
1832  for (int i=0; i<x.size(); i++)
1833  a[i]=x[i];
1834  }
1835 
1836  template<class Var>
1837  forceinline typename ArrayTraits<VarArgArray<Var>>::ArgsType
1838  VarArgArray<Var>::slice(int start, int inc, int maxN) {
1840  <typename ArrayTraits<VarArgArray<Var>>::ArgsType>
1841  (start,inc,maxN);
1842  }
1843 
1844  template<class Var>
1845  forceinline typename ArrayTraits<VarArgArray<Var>>::ArgsType&
1847  return
1849  <typename ArrayTraits<VarArgArray<Var>>::ArgsType>(x);
1850  }
1851 
1852  template<class Var>
1853  forceinline typename ArrayTraits<VarArgArray<Var>>::ArgsType&
1855  return
1857  <typename ArrayTraits<VarArgArray<Var>>::ArgsType>(x);
1858  }
1859 
1860  template<class Var>
1861  typename ArrayTraits<VarArgArray<Var>>::ArgsType
1863  return x.template concat
1864  <typename ArrayTraits<VarArgArray<Var>>::ArgsType>(y);
1865  }
1866 
1867  template<class Var>
1868  typename ArrayTraits<VarArgArray<Var>>::ArgsType
1869  operator +(const VarArgArray<Var>& x, const Var& y) {
1870  return x.template concat
1871  <typename ArrayTraits<VarArgArray<Var>>::ArgsType>(y);
1872  }
1873 
1874  template<class Var>
1875  typename ArrayTraits<VarArgArray<Var>>::ArgsType
1876  operator +(const Var& x, const VarArgArray<Var>& y) {
1877  VarArgArray<Var> xa(1);
1878  xa[0] = x;
1879  return xa.template concat
1880  <typename ArrayTraits<VarArgArray<Var>>::ArgsType>(y);
1881  }
1882 
1883  template<class Var>
1884  forceinline bool
1886  for (int i=0; i<n; i++)
1887  if (!a[i].assigned())
1888  return false;
1889  return true;
1890  }
1891 
1892 
1893  /*
1894  * Checking for multiple occurences of the same variable
1895  *
1896  */
1897  template<class Var>
1898  bool
1900  if ((x.size() == 0) || (y.size() == 0))
1901  return false;
1902  Region r;
1903  void** px = r.alloc<void*>(x.size());
1904  int j=0;
1905  for (int i=0; i<x.size(); i++)
1906  if (!x[i].assigned())
1907  px[j++] = x[i].varimp();
1908  if (j == 0)
1909  return false;
1910  void** py = r.alloc<void*>(y.size());
1911  int k=0;
1912  for (int i=0; i<y.size(); i++)
1913  if (!y[i].assigned())
1914  py[k++] = y[i].varimp();
1915  if (k == 0)
1916  return false;
1917  return Kernel::duplicates(px,j,py,k);
1918  }
1919 
1920  template<class Var>
1921  bool
1923  if (y.assigned())
1924  return false;
1925  for (int i=0; i<x.size(); i++)
1926  if (x[i].varimp() == y.varimp())
1927  return true;
1928  return false;
1929  }
1930 
1931  template<class Var>
1932  forceinline bool
1934  return same(y,x);
1935  }
1936 
1937  template<class Var>
1938  bool
1940  if (x.size() < 2)
1941  return false;
1942  Region r;
1943  void** px = r.alloc<void*>(x.size());
1944  int j=0;
1945  for (int i=0; i<x.size(); i++)
1946  if (!x[i].assigned())
1947  px[j++] = x[i].varimp();
1948  return (j > 1) && Kernel::duplicates(px,j);
1949  }
1950 
1951 
1952 
1953  /*
1954  * Interdependent code
1955  *
1956  */
1957 
1958  template<class Var>
1959  inline
1961  : n(a.size()) {
1962  if (n>0) {
1963  x = home.alloc<Var>(n);
1964  for (int i=0; i<n; i++)
1965  x[i] = a[i];
1966  } else {
1967  x = nullptr;
1968  }
1969  }
1970 
1971 
1972  /*
1973  * Printing of arrays
1974  *
1975  */
1976  template<class Char, class Traits, class Var>
1977  std::basic_ostream<Char,Traits>&
1978  operator <<(std::basic_ostream<Char,Traits>& os,
1979  const VarArray<Var>& x) {
1980  std::basic_ostringstream<Char,Traits> s;
1981  s.copyfmt(os); s.width(0);
1982  s << '{';
1983  if (x.size() > 0) {
1984  s << x[0];
1985  for (int i=1; i<x.size(); i++)
1986  s << ", " << x[i];
1987  }
1988  s << '}';
1989  return os << s.str();
1990  }
1991 
1992  template<class Char, class Traits, class View>
1993  std::basic_ostream<Char,Traits>&
1994  operator <<(std::basic_ostream<Char,Traits>& os,
1995  const ViewArray<View>& x) {
1996  std::basic_ostringstream<Char,Traits> s;
1997  s.copyfmt(os); s.width(0);
1998  s << '{';
1999  if (x.size() > 0) {
2000  s << x[0];
2001  for (int i=1; i<x.size(); i++)
2002  s << ", " << x[i];
2003  }
2004  s << '}';
2005  return os << s.str();
2006  }
2007 
2008  template<class Char, class Traits, class T>
2009  std::basic_ostream<Char,Traits>&
2010  operator <<(std::basic_ostream<Char,Traits>& os,
2011  const ArgArrayBase<T>& x) {
2012  std::basic_ostringstream<Char,Traits> s;
2013  s.copyfmt(os); s.width(0);
2014  s << '{';
2015  if (x.size() > 0) {
2016  s << x[0];
2017  for (int i=1; i<x.size(); i++)
2018  s << ", " << x[i];
2019  }
2020  s << '}';
2021  return os << s.str();
2022  }
2023 
2024 }
2025 
2026 // STATISTICS: kernel-other
int capacity
Allocated size of the array.
Definition: array.hpp:524
static T * copy(T *d, const T *s, long unsigned int n)
Copy n objects starting at s to d.
Definition: heap.hpp:583
const T * const_iterator
Type of the iterator used to iterate read-only through this array&#39;s elements.
Definition: array.hpp:570
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1569
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:908
void cancel(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:81
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
Definition: region.hpp:386
Var * iterator
Type of the iterator used to iterate through this array&#39;s elements.
Definition: array.hpp:114
std::reverse_iterator< const T * > const_reverse_iterator
Type of the iterator used to iterate backwards and read-only through this array&#39;s elements...
Definition: array.hpp:574
Var & reference
Type of a reference to the value type.
Definition: array.hpp:106
Base-class for propagators.
Definition: core.hpp:1023
Var * pointer
Type of a pointer to the value type.
Definition: array.hpp:110
Base-class for advisors.
Definition: core.hpp:1251
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const ArgArrayBase< T > &x)
Definition: array.hpp:2010
Variable arrays
Definition: array.hpp:60
T * iterator
Type of the iterator used to iterate through this array&#39;s elements.
Definition: array.hpp:568
Handle to region.
Definition: region.hpp:55
#define forceinline
Definition: config.hpp:185
const View & const_reference
Type of a constant reference to the value type.
Definition: array.hpp:249
Computation spaces.
Definition: core.hpp:1701
View * iterator
Type of the iterator used to iterate through this array&#39;s elements.
Definition: array.hpp:255
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
Definition: core.hpp:2794
View * pointer
Type of a pointer to the value type.
Definition: array.hpp:251
const Var & const_reference
Type of a constant reference to the value type.
Definition: array.hpp:108
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
std::reverse_iterator< const Var * > const_reverse_iterator
Type of the iterator used to iterate backwards and read-only through this array&#39;s elements...
Definition: array.hpp:120
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
Definition: heap.hpp:431
const FloatNum min
Smallest allowed float value.
Definition: float.hh:846
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Argument array for non-primitive types.
Definition: array.hpp:638
Gecode::IntArgs i({1, 2, 3, 4})
Var * x
Array of variables.
Definition: array.hpp:99
const View * const_pointer
Type of a read-only pointer to the value type.
Definition: array.hpp:253
FloatVal operator+(const FloatVal &x)
Definition: val.hpp:164
NNF * r
Right subtree.
Definition: bool-expr.cpp:242
int PropCond
Type for propagation conditions.
Definition: core.hpp:72
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:71
ArrayTraits< VarArgArray< Var > >::ArgsType operator+(const Var &x, const VarArgArray< Var > &y)
Definition: array.hpp:1876
bool same(VarArgArray< Var > x)
Definition: array.hpp:1939
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)
Definition: array.hpp:305
VarArray(void)
Default constructor (array of size 0)
Definition: array.hpp:883
T & reference
Type of a reference to the value type.
Definition: array.hpp:560
bool duplicates(void **p, int n)
Check whether p has duplicates among its n elements (changes p)
Definition: array.cpp:39
#define GECODE_KERNEL_EXPORT
Definition: kernel.hh:70
View arrays.
Definition: array.hpp:235
int n
Number of variables (size)
Definition: array.hpp:97
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc to all views.
Definition: array.hpp:1331
bool shared(ViewArray< View > x)
Definition: array.hpp:1468
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
Definition: array.hpp:1899
Boolean integer variables.
Definition: int.hh:512
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:767
T * pointer
Type of a pointer to the value type.
Definition: array.hpp:564
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
View & reference
Type of a reference to the value type.
Definition: array.hpp:247
Base class for variables.
Definition: var.hpp:40
void free(T *b, long unsigned int n)
Delete n objects starting at b.
Definition: heap.hpp:457
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
Base-class for argument arrays.
Definition: array.hpp:519
Heap heap
The single global heap.
Definition: heap.cpp:44
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:43
const Var * const_pointer
Type of a read-only pointer to the value type.
Definition: array.hpp:112
Post propagator for SetVar x
Definition: set.hh:767
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition: val-sel.hpp:39
int n
Number of elements.
Definition: array.hpp:522
Traits of arrays in Gecode.
Definition: array.hpp:76
const T & const_reference
Type of a constant reference to the value type.
Definition: array.hpp:562
Gecode toplevel namespace
Argument array for variables.
Definition: array.hpp:61
const int capacity[n_warehouses]
Capacity of a single warehouse.
Definition: warehouses.cpp:49
std::reverse_iterator< const View * > const_reverse_iterator
Type of the iterator used to iterate backwards and read-only through this array&#39;s elements...
Definition: array.hpp:261
ViewArray(Space &home, const VarArgArray< Var > &a)
Initialize from variable argument array a (copy elements)
Definition: array.hpp:287
std::reverse_iterator< T * > reverse_iterator
Type of the iterator used to iterate backwards through this array&#39;s elements.
Definition: array.hpp:572
bool shared(ViewArray< ViewX > x, ViewArray< ViewY > y)
Definition: array.hpp:1428
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:92
const Var * const_iterator
Type of the iterator used to iterate read-only through this array&#39;s elements.
Definition: array.hpp:116
View value_type
Type of the view stored in this array.
Definition: array.hpp:245
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1138
const View * const_iterator
Type of the iterator used to iterate read-only through this array&#39;s elements.
Definition: array.hpp:257
std::reverse_iterator< View * > reverse_iterator
Type of the iterator used to iterate backwards through this array&#39;s elements.
Definition: array.hpp:259
const T * const_pointer
Type of a read-only pointer to the value type.
Definition: array.hpp:566
void update(IntSet &y, Space &home, IntSet &py)
Definition: rel.hpp:103
const unsigned int slice
Size of a slice in a portfolio and scale factor for restarts(in number of failures) ...
Definition: search.hh:128
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&#39;s elements.
Definition: array.hpp:118
T * a
Element array.
Definition: array.hpp:526