21 #ifndef __stridedRange_hpp__
22 #define __stridedRange_hpp__
45 static inline const T maxVal = largestPositive<T>();
46 static inline const T minVal = largestNegative<T>();
72 if(!parseRange(rangeString,begin_,end_, stride_))
75 "bad input for the range. It should have the form of begin:stride:end \n";
82 begin_(dict.getVal<T>(
"begin")),
83 end_(dict.getVal<T>(
"end")),
84 stride_(dict.getVal<T>(
"stride"))
106 return val>= begin_ && val<= end_;
113 if(!isInRange(val))
return false;
114 if(T dist = val-begin_;
abs(dist%stride_)<= epsilon)
return true;
115 if(
equal(val,begin_))
return true;
116 if(
equal(val,end_))
return true;
129 auto col1 = rangeString.find_first_of(
":");
131 if(col1 == 0 || col1==std::string::npos)
return false;
133 auto beginCh = rangeString.substr(0,col1);
135 auto col2 = rangeString.find_first_of(
":",col1+1);
137 if(col1 == col2 || col2==std::string::npos)
return false;
139 auto strideCh = rangeString.substr(col1+1,col2-col1-1);
141 auto endCh = rangeString.substr(col2+1);
143 if(!
readValue(beginCh,begin))
return false;
144 if(!
readValue(strideCh, stride))
return false;
157 if(!isInRange(val))
return false;
158 real dist = val-begin_;
160 (dist-(
static_cast<uint64>((dist+0.01*epsilon)/stride_)*stride_))
161 )<= epsilon)
return true;
162 if(
equal(val,begin_))
return true;
163 if(
equal(val,end_))
return true;
170 #endif //__stridedRange_hpp__