Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libdeng2|Range: Added clamp() method
  • Loading branch information
skyjake committed Jun 20, 2013
1 parent 2089b1a commit bd30fc7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doomsday/libdeng2/include/de/core/range.h
Expand Up @@ -39,6 +39,11 @@ struct Range
explicit Range(Type const &a = 0, Type const &b = 0) : start(a), end(b) {}
inline Type size() const { return end - start; }
inline bool contains(Type const &i) const { return i >= start && i < end; }
inline Type clamp(Type const &i) const {
if(i < start) return start;
if(i > end) return end;
return i;
}
inline Range &operator |= (Type const &value) {
start = de::min(start, value);
end = de::max(end, value);
Expand Down

0 comments on commit bd30fc7

Please sign in to comment.