idxarray.icc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 namespace Gecode { namespace Set { namespace Select {
00025
00026 template <class View>
00027 forceinline IdxView<View>*
00028 IdxView<View>::allocate(Space* home, int n) {
00029 return
00030 reinterpret_cast<IdxView<View>*>(home->alloc(sizeof(IdxView<View>)*n));
00031 }
00032
00033 template <class View>
00034 IdxViewArray<View>::IdxViewArray(void) : xs(NULL), n(0) {}
00035
00036 template <class View>
00037 IdxViewArray<View>::IdxViewArray(const IdxViewArray<View>& a) {
00038 n = a.n; xs = a.xs;
00039 }
00040
00041 template <class View>
00042 IdxViewArray<View>::IdxViewArray(Space* home, const SetVarArgs& xa)
00043 : xs(NULL) {
00044 n = xa.size();
00045 if (n>0) {
00046 xs = IdxView<View>::allocate(home, n);
00047 for (int i = n; i--; ) {
00048 SetView xav(xa[i]);
00049 View xavv(xav);
00050 xs[i].idx = i; xs[i].var = xavv;
00051 }
00052 }
00053 }
00054
00055 template <class View>
00056 forceinline int
00057 IdxViewArray<View>::size(void) const {
00058 return n;
00059 }
00060
00061 template <class View>
00062 forceinline void
00063 IdxViewArray<View>::size(int n0) {
00064 n = n0;
00065 }
00066
00067 template <class View>
00068 forceinline IdxView<View>&
00069 IdxViewArray<View>::operator[](int i) {
00070 assert((i >= 0) && (i < size()));
00071 return xs[i];
00072 }
00073
00074 template <class View>
00075 forceinline const IdxView<View>&
00076 IdxViewArray<View>::operator[](int i) const {
00077 assert((i >= 0) && (i < size()));
00078 return xs[i];
00079 }
00080
00081 template <class View>
00082 void
00083 IdxViewArray<View>::subscribe(Space* home, Propagator* p, PropCond pc,
00084 bool process) {
00085 for (int i = n; i--; )
00086 xs[i].var.subscribe(home,p,pc,process);
00087 }
00088
00089 template <class View>
00090 void
00091 IdxViewArray<View>::cancel(Space* home, Propagator* p, PropCond pc) {
00092 for (int i = n; i--; )
00093 xs[i].var.cancel(home,p,pc);
00094 }
00095
00096 template <class View>
00097 void
00098 IdxViewArray<View>::update(Space* home, bool share, IdxViewArray<View>& a) {
00099 n = a.size();
00100 if (n>0) {
00101 xs = IdxView<View>::allocate(home,n);
00102 for (int i=n; i--; ) {
00103 xs[i].idx = a[i].idx;
00104 xs[i].var.update(home,share,a[i].var);
00105 }
00106 }
00107 }
00108
00109 }}}
00110
00111
00112