IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
Interval.cs
Go to the documentation of this file.
1using System;
5
7{
8 namespace Detail
9 {
16
20 public class IntervalT<T> where T : struct, IComparable<T>
21 {
30 public IntervalT(T minimum, T maximum)
31 {
32 if (minimum.CompareTo(maximum) > 0)
33 {
35 "Maximum value has to be bigger than or equal to the minimum value");
36 }
37
38 Minimum = minimum;
39 Maximum = maximum;
40 }
41
45 public T Minimum { get; }
46
50 public T Maximum { get; }
51
59 public override bool Equals(object? obj)
60 {
61 if (obj is null)
62 {
63 return false;
64 }
65
66 if (ReferenceEquals(this, obj))
67 {
68 return true;
69 }
70
71 if (!(obj is IntervalT<T> other))
72 {
73 return false;
74 }
75
76 return Equals(other);
77 }
78
86 protected bool Equals(IntervalT<T> other)
87 {
88 return Minimum.Equals(other.Minimum) && Maximum.Equals(other.Maximum);
89 }
90
94 public override int GetHashCode()
95 {
96 return (Minimum, Maximum).GetHashCode();
97 }
98
102 public override string ToString()
103 {
104 return Formatting.Invariant($"{GetType().Name}{{ Minimum = {Minimum}, Maximum = {Maximum} }}");
105 }
106 }
107 }
108
112
116 public class Interval : IntervalT<int>
117 {
123 public Interval(int minimum, int maximum)
124 : base(minimum, maximum)
125 {
126 }
127 }
128
132
136 public class IntervalU : IntervalT<uint>
137 {
143 public IntervalU(uint minimum, uint maximum)
144 : base(minimum, maximum)
145 {
146 }
147 }
148
152
156 public class IntervalF : IntervalT<float>
157 {
163 public IntervalF(float minimum, float maximum)
164 : base(minimum, maximum)
165 {
166 }
167 }
168
172
176 public class IntervalD : IntervalT<double>
177 {
183 public IntervalD(double minimum, double maximum)
184 : base(minimum, maximum)
185 {
186 }
187 }
188}
Exception thrown when an invalid parameter is detected.
Represents an interval consisting of a lower and upper boundary value.
Definition Interval.cs:21
override int GetHashCode()
Returns a hash code for the current interval.
Definition Interval.cs:94
override bool Equals(object? obj)
Determines whether the specified object is equal to the current interval.
Definition Interval.cs:59
override string ToString()
Returns a string representation of the interval.
Definition Interval.cs:102
IntervalT(T minimum, T maximum)
Initializes a new instance of the IntervalT<T> class with specified boundaries.
Definition Interval.cs:30
T Maximum
Gets the upper boundary of the interval.
Definition Interval.cs:50
T Minimum
Gets the lower boundary of the interval.
Definition Interval.cs:45
Represents an interval with double-precision floating-point boundaries.
Definition Interval.cs:177
IntervalD(double minimum, double maximum)
Initializes a new instance of the IntervalD class with specified boundaries.
Definition Interval.cs:183
Represents an interval with floating-point boundaries.
Definition Interval.cs:157
IntervalF(float minimum, float maximum)
Initializes a new instance of the IntervalF class with specified boundaries.
Definition Interval.cs:163
Represents an interval with signed integer boundaries.
Definition Interval.cs:117
Interval(int minimum, int maximum)
Initializes a new instance of the Interval class with specified boundaries.
Definition Interval.cs:123
Represents an interval with unsigned integer boundaries.
Definition Interval.cs:137
IntervalU(uint minimum, uint maximum)
Initializes a new instance of the IntervalU class with specified boundaries.
Definition Interval.cs:143