iter.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 #include <algorithm>
00039
00040 namespace Gecode { namespace Int {
00041
00042 template<class TaskView, SortTaskOrder sto, bool inc>
00043 forceinline
00044 TaskViewIter<TaskView,sto,inc>::TaskViewIter(void) {}
00045
00046 template<class TaskView, SortTaskOrder sto, bool inc>
00047 forceinline
00048 TaskViewIter<TaskView,sto,inc>
00049 ::TaskViewIter(Region& r, const TaskViewArray<TaskView>& t)
00050 : map(r.alloc<int>(t.size())), i(t.size()-1) {
00051 sort<TaskView,sto,!inc>(map,t);
00052 }
00053
00054 template<class TaskView, SortTaskOrder sto, bool inc>
00055 forceinline bool
00056 TaskViewIter<TaskView,sto,inc>::operator ()(void) const {
00057 return i>=0;
00058 }
00059 template<class TaskView, SortTaskOrder sto, bool inc>
00060 forceinline int
00061 TaskViewIter<TaskView,sto,inc>::left(void) const {
00062 return i+1;
00063 }
00064 template<class TaskView, SortTaskOrder sto, bool inc>
00065 forceinline void
00066 TaskViewIter<TaskView,sto,inc>::operator ++(void) {
00067 i--;
00068 }
00069
00070 template<class TaskView, SortTaskOrder sto, bool inc>
00071 forceinline int
00072 TaskViewIter<TaskView,sto,inc>::task(void) const {
00073 return map[i];
00074 }
00075
00076
00077 template<class OptTaskView, SortTaskOrder sto, bool inc>
00078 forceinline
00079 ManTaskViewIter<OptTaskView,sto,inc>
00080 ::ManTaskViewIter(Region& r, const TaskViewArray<OptTaskView>& t) {
00081 map = r.alloc<int>(t.size()); i=0;
00082 for (int j=t.size(); j--; )
00083 if (t[j].mandatory())
00084 map[i++]=j;
00085 sort<OptTaskView,sto,!inc>(map,i,t);
00086 i--;
00087 }
00088
00089
00090 }}
00091
00092