SRange.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionCore.h>
5 
6 
7 namespace ion
8 {
9 
10  template <typename T>
11  struct SRange
12  {
13  static SRange const Full;
14  static SRange const Empty;
15 
16  bool Contains(T const value) const
17  {
18  return value >= Minimum && value <= Maximum;
19  }
20 
21  bool IsEmpty() const
22  {
23  return Minimum > Maximum;
24  }
25 
26  bool IsSingular() const
27  {
28  return Equals(Minimum, Maximum);
29  }
30 
31  T Normalize(T const value) const
32  {
33  return (value - Minimum) / (Maximum - Minimum);
34  }
35 
36  T Size() const
37  {
38  return Maximum - Minimum;
39  }
40 
42  {
43  * this = Empty;
44  }
45 
46  SRange(T const minimum, T const maximum)
47  : Minimum(minimum), Maximum(maximum)
48  {}
49 
50  SRange & operator = (SRange const & Other)
51  {
52  Minimum = Other.Minimum;
53  Maximum = Other.Maximum;
54  return * this;
55  }
56 
59  };
60 
61  template <typename T>
62  SRange<T> const SRange<T>::Full = SRange<T>(-std::numeric_limits<T>::max(), std::numeric_limits<T>::max());
63 
64  template <typename T>
65  SRange<T> const SRange<T>::Empty = SRange<T>(std::numeric_limits<T>::max(), -std::numeric_limits<T>::max());
66 
67 }
SRange(T const minimum, T const maximum)
Definition: SRange.h:46
SRange & operator=(SRange const &Other)
Definition: SRange.h:50
bool IsSingular() const
Definition: SRange.h:26
SRange()
Definition: SRange.h:41
static SRange const Empty
Definition: SRange.h:14
static SRange const Full
Definition: SRange.h:13
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
T Minimum
Definition: SRange.h:57
T Normalize(T const value) const
Definition: SRange.h:31
bool Contains(T const value) const
Definition: SRange.h:16
Definition: SRange.h:11
T Maximum
Definition: SRange.h:58
T Size() const
Definition: SRange.h:36
bool IsEmpty() const
Definition: SRange.h:21