int-trace-view.hpp
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
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 namespace Gecode { namespace Int {
00039
00041 class IntTraceView {
00042 protected:
00044 RangeList* dom;
00045 public:
00047 IntTraceView(void);
00049 IntTraceView(Space& home, IntView y);
00051 RangeList* ranges(void) const;
00053 void prune(Space& home, IntView y, const Delta& d);
00055 void update(Space& home, bool share, IntTraceView x);
00057 static unsigned long long int slack(IntView x);
00058 };
00059
00060 forceinline
00061 IntTraceView::IntTraceView(void) {}
00062
00063 forceinline
00064 IntTraceView::IntTraceView(Space& home, IntView y) {
00065 ViewRanges<IntView> yr(y);
00066 RangeList::copy(home, dom, yr);
00067 }
00068
00069 forceinline RangeList*
00070 IntTraceView::ranges(void) const {
00071 return dom;
00072 }
00073
00074 forceinline void
00075 IntTraceView::prune(Space& home, IntView y, const Delta& d) {
00076 if (y.range() && (dom->next() == NULL)) {
00077 dom->min(y.min()); dom->max(y.max());
00078 } else if (!y.any(d) && (y.max(d)+1 == y.min())) {
00079
00080 if (y.min() > dom->max()) {
00081 RangeList* p = dom;
00082 RangeList* l = p->next();
00083 while ((l != NULL) && (l->max() < y.min())) {
00084 p=l; l=l->next();
00085 }
00086 dom->dispose(home,p);
00087 dom = l;
00088 }
00089 dom->min(y.min());
00090 } else if (!y.any(d) && (y.max()+1 == y.min(d))) {
00091
00092 if ((y.max() <= dom->max()) && (dom->next() == NULL)) {
00093 dom->max(y.max());
00094 } else {
00095 RangeList* p = dom;
00096 RangeList* l = p->next();
00097 while ((l != NULL) && (l->min() <= y.max())) {
00098 p=l; l=l->next();
00099 }
00100 p->max(y.max());
00101 if (p->next() != NULL)
00102 p->next()->dispose(home);
00103 p->next(NULL);
00104 }
00105 } else {
00106
00107 ViewRanges<IntView> yr(y);
00108 RangeList::overwrite(home,dom,yr);
00109 }
00110 }
00111
00112 forceinline void
00113 IntTraceView::update(Space& home, bool, IntTraceView y) {
00114 Iter::Ranges::RangeList yr(y.dom);
00115 RangeList::copy(home,dom,yr);
00116 }
00117
00118 forceinline unsigned long long int
00119 IntTraceView::slack(IntView x) {
00120 return x.width()-1;
00121 }
00122
00123
00124 }}
00125
00126