VVISF & VVGL
VVGL_Range.hpp
1 #ifndef VVGL_Range_h
2 #define VVGL_Range_h
3 
4 #include "VVGL_Defines.hpp"
5 
6 
7 
8 
9 namespace VVGL
10 {
11 
12 
13 
14 
19 struct Range {
20  size_t loc = 0;
21  size_t len = 0;
22 
23  Range() {}
24  Range(const size_t & inLoc, const size_t & inLen) : loc(inLoc), len(inLen) {}
25 
27  inline size_t max() const { return loc+len; }
29  inline size_t min() const { return loc; }
31  inline bool intersects(const Range & n) const {
32  size_t tmpLoc = this->min();
33  size_t tmpMin = n.min();
34  size_t tmpMax = n.max();
35  if (tmpLoc>=tmpMin && tmpLoc<=tmpMax)
36  return true;
37  tmpLoc = this->max();
38  if (tmpLoc>=tmpMin && tmpLoc<=tmpMax)
39  return true;
40  return false;
41  }
42  Range & operator=(const Range & n) { loc=n.loc; len=n.len; return *this; }
43  bool operator==(const Range & n) { return (loc==n.loc && len==n.len); }
44 };
45 
46 
47 
48 
49 }
50 
51 
52 
53 
54 #endif /* VVGL_Range_h */
Definition: GLBuffer.hpp:13
Describes an integer range using a value (loc) and size (len).
Definition: VVGL_Range.hpp:19
size_t min() const
Returns the min value of the range.
Definition: VVGL_Range.hpp:29
bool intersects(const Range &n) const
Returns a true if the receiver intersects the passed range.
Definition: VVGL_Range.hpp:31
size_t max() const
Returns the max value of the range.
Definition: VVGL_Range.hpp:27