SystemEX  Lacking
Additional generic collection types missing in .net
SystemEx.NumberRangeIterator< T > Struct Template Reference

Forward iterator over a normalized numeric range. Supports stepping by one unit and exposes the current value and end-of-range state. More...

Inheritance diagram for SystemEx.NumberRangeIterator< T >:
Collaboration diagram for SystemEx.NumberRangeIterator< T >:

Public Member Functions

 NumberRangeIterator (T start, T end)
 Initializes a new iterator positioned at start and iterating until end .
void Forward ()
 Moves the iterator one step forward.
void Forward (long i)
 Moves the iterator N step forward.
IIterator< T > Clone ()
 Creates a copy of this iterator at its current position.
override bool Equals (object? obj)
 Compares two iterators for equality based on their current position and end boundary.
override int GetHashCode ()
 Computes a hash code for this iterator.

Static Public Member Functions

static bool operator== (NumberRangeIterator< T > left, NumberRangeIterator< T > right)
 Compares two iterators for equality. Two iterators are equal if both their current position and end boundary match.
static bool operator!= (NumberRangeIterator< T > left, NumberRangeIterator< T > right)
 Compares two iterators for inequality.

Properties

Current [get]
 Gets the element at the current iterator position.
bool IsEnd [get]
 Indicates whether the iterator has reached the end boundary.

Detailed Description

Forward iterator over a normalized numeric range. Supports stepping by one unit and exposes the current value and end-of-range state.

Template Parameters
TNumeric type implementing INumber<T>.
Type Constraints
T :INumber<T> 

Member Function Documentation

◆ Clone()

IIterator< T > SystemEx.NumberRangeIterator< T >.Clone ( )

Creates a copy of this iterator at its current position.

Returns
A new iterator instance positioned identically.

Implements SystemEx.Collections.Generic.Interfaces.IIterator< T >.

82 => new NumberRangeIterator<T>(m_current, m_end);
Here is the call graph for this function:

◆ Equals()

override bool SystemEx.NumberRangeIterator< T >.Equals ( object? obj)

Compares two iterators for equality based on their current position and end boundary.

89 => obj is NumberRangeIterator<T> it &&
90 it.m_current.Equals(m_current) &&
91 it.m_end.Equals(m_end);
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Forward() [1/2]

void SystemEx.NumberRangeIterator< T >.Forward ( )

Moves the iterator one step forward.

Implements SystemEx.Collections.Generic.Interfaces.IIterator.

62 {
63 if ( !IsEnd )
64 m_current += T.One;
65 }
Here is the caller graph for this function:

◆ Forward() [2/2]

void SystemEx.NumberRangeIterator< T >.Forward ( long i)

Moves the iterator N step forward.

Implements SystemEx.Collections.Generic.Interfaces.IIterator.

70 {
71 var n = i;
72 while ( n > 0 ) {
73 --n;
74 Forward();
75 }
76 }
Here is the call graph for this function:

◆ GetHashCode()

override int SystemEx.NumberRangeIterator< T >.GetHashCode ( )

Computes a hash code for this iterator.

97 => HashCode.Combine(m_current, m_end);

◆ NumberRangeIterator()

SystemEx.NumberRangeIterator< T >.NumberRangeIterator ( T start,
T end )

Initializes a new iterator positioned at start and iterating until end .

Parameters
startInitial iterator position.
endEnd boundary (inclusive).
44 {
45 m_current = start;
46 m_end = end;
47 }
Here is the caller graph for this function:

◆ operator!=()

bool SystemEx.NumberRangeIterator< T >.operator!= ( NumberRangeIterator< T > left,
NumberRangeIterator< T > right )
static

Compares two iterators for inequality.

Parameters
leftLeft iterator.
rightRight iterator.
Returns
True if the iterators differ.
117 {
118 return !left.Equals(right);
119 }
Here is the call graph for this function:

◆ operator==()

bool SystemEx.NumberRangeIterator< T >.operator== ( NumberRangeIterator< T > left,
NumberRangeIterator< T > right )
static

Compares two iterators for equality. Two iterators are equal if both their current position and end boundary match.

Parameters
leftLeft iterator.
rightRight iterator.
Returns
True if both iterators are equal.
107 {
108 return left.Equals(right);
109 }
Here is the call graph for this function:

Property Documentation

◆ Current

T SystemEx.NumberRangeIterator< T >.Current
get

Gets the element at the current iterator position.

Implements SystemEx.Collections.Generic.Interfaces.IForwardIterator< T >.

◆ IsEnd

bool SystemEx.NumberRangeIterator< T >.IsEnd
get

Indicates whether the iterator has reached the end boundary.

Implements SystemEx.Collections.Generic.Interfaces.IForwardIterator< T >.


The documentation for this struct was generated from the following file:
  • NumberRangeIterrator.cs