src/cpsp/gecode/GC_StlSetRangeIterator.cc
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 #include "cpsp/gecode/GC_StlSetRangeIterator.hh" 00021 00022 namespace cpsp 00023 { 00024 namespace gecode 00025 { 00026 00027 GC_StlSetRangeIterator::GC_StlSetRangeIterator() : 00028 data(NULL), noFurtherRange(true) 00029 { 00030 getNextRange(); 00031 } 00032 00033 GC_StlSetRangeIterator::GC_StlSetRangeIterator(const std::set<int>* data_) : 00034 data(data_), noFurtherRange(false) 00035 { 00036 if (data != NULL) 00037 actElem = data->begin(); 00038 getNextRange(); 00039 } 00040 00041 GC_StlSetRangeIterator::~GC_StlSetRangeIterator() 00042 { 00043 } 00044 00045 void 00046 GC_StlSetRangeIterator::getNextRange() { 00047 if (data==NULL || actElem == data->end()) { 00048 noFurtherRange = true; 00049 return; 00050 } 00051 // find next range 00052 nextMin = *actElem; 00053 nextMax = nextMin; 00054 // build up new upper bound until end of set reached or gap in 00055 // sequence 00056 while ( (++actElem != data->end()) && (*actElem == (nextMax+1))) { 00057 nextMax++; 00058 } 00059 } 00060 00061 } //namespace gecode 00062 } // namespace cpsp