/* * Range.hpp * * Created on: Jul 22, 2010 * Author: crueger */ #ifndef RANGE_HPP_ #define RANGE_HPP_ template struct range { range(const T&,const T&); bool isInRange(const T&) const; bool isBefore(const T&) const; bool isBeyond(const T&) const; T first; T last; }; template range::range(const T &_first,const T &_last) : first(_first),last(_last) {} template bool range::isInRange(const T &value) const{ return first <= value && value < last; } template bool range::isBefore(const T &value) const{ return value < first; } template bool range::isBeyond(const T &value) const{ return last <= value; } template range makeRange(const T&first, const T&last){ return range(first,last); } template bool operator<(const range &x, const range &y){ return (x.first!=y.first)?x.first bool operator==(const range &x,const range &y){ return x.first==y.first && x.last==y.last; } template bool operator!= (const range& x, const range& y) { return !(x==y); } template bool operator> (const range& x, const range& y) { return y bool operator<=(const range& x, const range& y) { return !(y bool operator>= (const range& x, const range& y) { return !(x