Provides a cursor-based stepper over a normalized numeric range. The stepper moves from Start to End in fixed increments and exposes forward/backward stepping, reset, and enumeration.
More...
|
| | NumberRangeStepper (NumberRange< T > orig, T step) |
| | Initializes a new stepper for the specified range using the given step size. The input range is normalized to ensure monotonic forward stepping.
|
| IEnumerator< T > | GetEnumerator () |
| | Enumerates all values from Start to End using the configured step size.
|
| T | Next () |
| | Advances the cursor by one step. If no further step is possible, the cursor is clamped to the End value.
|
| T | Next (T step) |
| | Advances the cursor by a dynamic step value. If the next position exceeds the range, the cursor is clamped to the End value.
|
| T | Prev (T step) |
| | Moves the cursor backward by a dynamic step value. If the previous position would fall below the original start value, the cursor is clamped to the original Start.
|
| T | Prev () |
| | Moves the cursor one step backward. If no backward step is possible, the cursor is clamped to the original start value.
|
| T | Reset () |
| | Resets the cursor to the original start value.
|
| bool | HasNext () |
| | Determines whether a forward step remains within the range.
|
| bool | HasPrev () |
| | Determines whether a backward step remains within the range.
|
| bool | HasNext (T step) |
| | Determines whether a forward step of the given size remains within the range.
|
| bool | HasPrev (T step) |
| | Determines whether a backward step of the given size remains within the range.
|
| bool | Equals (NumberRangeStepper< T >? other) |
| | Checks equality based on range and step size. The original start value is derived from the normalized range and therefore does not need to be compared explicitly.
|
| override bool | Equals (object? obj) |
| override int | GetHashCode () |
| | Computes a hash code based on the range and step size.
|
Provides a cursor-based stepper over a normalized numeric range. The stepper moves from Start to End in fixed increments and exposes forward/backward stepping, reset, and enumeration.
- Template Parameters
-
| T | Numeric type implementing INumber<T>. |
◆ Equals() [1/2]
Checks equality based on range and step size. The original start value is derived from the normalized range and therefore does not need to be compared explicitly.
- Parameters
-
| other | Stepper to compare with. |
- Returns
- True if both steppers are equivalent.
160 {
161 if ( other == null ) return false;
162
163 return m_current.Equals(other.m_current) &&
164 m_step.Equals(other.m_step) ;
165 }
◆ Equals() [2/2]
| override bool SystemEx.Base.NumberRangeStepper< T >.Equals |
( |
object? | obj | ) |
|
167 {
168 return Equals(obj as NumberRangeStepper<T>);
169 }
◆ GetEnumerator()
| IEnumerator< T > SystemEx.Base.NumberRangeStepper< T >.GetEnumerator |
( |
| ) |
|
Enumerates all values from Start to End using the configured step size.
- Returns
- Sequence of stepped values.
54 {
55 for ( T i = m_current.From; i <= m_current.To; i += m_step ) {
56 yield return i;
57 }
58 }
◆ GetHashCode()
| override int SystemEx.Base.NumberRangeStepper< T >.GetHashCode |
( |
| ) |
|
Computes a hash code based on the range and step size.
174 {
175 return HashCode.Combine(m_current, m_current, m_step);
176 }
◆ HasNext() [1/2]
| bool SystemEx.Base.NumberRangeStepper< T >.HasNext |
( |
| ) |
|
Determines whether a forward step remains within the range.
121 =>
122 ( (m_current.From + m_step) < m_current.To ) ;
◆ HasNext() [2/2]
| bool SystemEx.Base.NumberRangeStepper< T >.HasNext |
( |
T | step | ) |
|
Determines whether a forward step of the given size remains within the range.
- Parameters
-
| step | Dynamic step size to test. |
- Returns
- True if
Start + step is still strictly below End; otherwise false.
139 => (m_current.From + step) < m_current.To;
◆ HasPrev() [1/2]
| bool SystemEx.Base.NumberRangeStepper< T >.HasPrev |
( |
| ) |
|
Determines whether a backward step remains within the range.
127 =>
128 ((m_current.From - m_step) >= m_startOld);
◆ HasPrev() [2/2]
| bool SystemEx.Base.NumberRangeStepper< T >.HasPrev |
( |
T | step | ) |
|
Determines whether a backward step of the given size remains within the range.
- Parameters
-
| step | Dynamic step size to test. |
- Returns
- True if
Start - step is still greater than or equal to the original start value; otherwise false.
150 => (m_current.From - step) >= m_startOld;
◆ Next() [1/2]
| T SystemEx.Base.NumberRangeStepper< T >.Next |
( |
| ) |
|
Advances the cursor by one step. If no further step is possible, the cursor is clamped to the End value.
- Returns
- The updated cursor position.
67 {
68 if( HasNext() ) m_current.From += m_step;
69 else m_current.From = m_current.To;
70
71 return m_current.From;
72 }
◆ Next() [2/2]
| T SystemEx.Base.NumberRangeStepper< T >.Next |
( |
T | step | ) |
|
Advances the cursor by a dynamic step value. If the next position exceeds the range, the cursor is clamped to the End value.
- Parameters
-
| step | Dynamic step size to apply. |
- Returns
- The updated cursor position.
79 {
80 if ( HasNext(step) ) m_current.From += step;
81 else m_current.From = m_current.To;
82
83 return m_current.From;
84 }
◆ NumberRangeStepper()
| SystemEx.Base.NumberRangeStepper< T >.NumberRangeStepper |
( |
NumberRange< T > | orig, |
|
|
T | step ) |
Initializes a new stepper for the specified range using the given step size. The input range is normalized to ensure monotonic forward stepping.
- Parameters
-
| orig | Original range to iterate over. |
| step | Step size applied to the cursor. |
44 {
45 m_step = step;
46 m_current = orig.Normalize();
47 m_startOld = m_current.From;
48 }
◆ Prev() [1/2]
| T SystemEx.Base.NumberRangeStepper< T >.Prev |
( |
| ) |
|
Moves the cursor one step backward. If no backward step is possible, the cursor is clamped to the original start value.
- Returns
- The updated cursor position.
103 {
104 if ( HasPrev() ) m_current.From -= m_step;
105 else m_current.From = m_startOld;
106 return m_current.From;
107 }
◆ Prev() [2/2]
| T SystemEx.Base.NumberRangeStepper< T >.Prev |
( |
T | step | ) |
|
Moves the cursor backward by a dynamic step value. If the previous position would fall below the original start value, the cursor is clamped to the original Start.
- Parameters
-
| step | Dynamic step size to apply. |
- Returns
- The updated cursor position.
92 {
93 if ( HasPrev(step) ) m_current.From -= step;
94 else m_current.From = m_startOld;
95 return m_current.From;
96 }
◆ Reset()
| T SystemEx.Base.NumberRangeStepper< T >.Reset |
( |
| ) |
|
Resets the cursor to the original start value.
- Returns
- The reset cursor position.
113 {
114 m_current.From = m_startOld;
115 return m_current.From;
116 }
The documentation for this class was generated from the following file: