src/cpsp/gecode/GC_StlSetRangeIterator.hh
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Martin Mann http://www.bioinf.uni-freiburg.de/~mmann/ 00004 * 00005 * Contributing authors: 00006 * Sebastian Will http://www.bioinf.uni-freiburg.de/~will/ 00007 * 00008 * Copyright: 00009 * Martin Mann, 2007 00010 * 00011 * This file is part of the CPSP-tools package: 00012 * http://www.bioinf.uni-freiburg.de/sw/cpsp/ 00013 * 00014 * See the file "LICENSE" for information on usage and 00015 * redistribution of this file, and for a 00016 * DISCLAIMER OF ALL WARRANTIES. 00017 * 00018 */ 00019 00020 #ifndef GC_STLSETRANGEITERATOR_HH_ 00021 #define GC_STLSETRANGEITERATOR_HH_ 00022 00023 00024 #include <set> 00025 #include <iostream> 00026 00027 namespace cpsp 00028 { 00029 namespace gecode 00030 { 00031 00036 class GC_StlSetRangeIterator 00037 { 00038 private: 00039 const std::set<int>* data; 00040 std::set<int>::const_iterator actElem; 00041 00042 bool noFurtherRange; 00043 00044 int nextMin, nextMax; 00045 00047 void getNextRange(); 00048 public: 00049 GC_StlSetRangeIterator(); 00050 GC_StlSetRangeIterator(const std::set<int>* data_); 00051 virtual ~GC_StlSetRangeIterator(); 00052 00053 void init(const std::set<int>* const data_) { 00054 data = data_; 00055 noFurtherRange = false; 00056 if (data != NULL) 00057 actElem = data->begin(); 00058 getNextRange(); 00059 } 00060 00061 bool operator()(void) const { return !noFurtherRange; } 00062 void operator++(void) { getNextRange(); } 00063 00064 int min(void) const { return nextMin; } 00065 int max(void) const { return nextMax; } 00066 unsigned int width(void) { return nextMax-nextMin+1; } 00067 00068 00069 }; 00070 00071 } 00072 } 00073 00074 #endif /*GC_STLSETRANGEITERATOR_HH_*/