Enhanced C#
Language of your choice: library documentation
Nested classes | Public fields | Public static fields | Properties | Public Member Functions | List of all members
Loyc.Collections.NumRange< Num, Math > Struct Template Reference

Represents a range of integers of a specified data type. More...


Source file:
Inheritance diagram for Loyc.Collections.NumRange< Num, Math >:
Loyc.Collections.IIsEmpty

Remarks

Represents a range of integers of a specified data type.

Template Parameters
NumAny numeric type
MathTrait type that implements math operations for the type, e.g. for Int32, use Loyc.Math.MathI.

TODO: unit tests.

Note: if the low value is the minimum value of an integer type (e.g. int.MinValue of int) then the Enumerator will not work (MoveNext() will return false). Also, if the difference between the min and max value is int.MaxValue or more, the Count property will overflow and return an incorrect value.

Type Constraints
Num :IConvertible 
Math :IMath<Num> 
Math :new() 

Nested classes

struct  Enumerator
 

Public fields

Num _lo
 
Num _hi
 
int _count
 

Public static fields

static Math M = new Math()
 

Properties

Num Lo [get]
 
Num Hi [get]
 
bool IsEmpty [get]
 
int Count [get]
 
Num this[int index] [get]
 
bool ICollection< Num >. IsReadOnly [get]
 
- Properties inherited from Loyc.Collections.IIsEmpty
bool IsEmpty [get]
 

Public Member Functions

 NumRange (Num low, Num highIncl)
 
Num TryGet (int index, out bool fail)
 
int IndexOf (Num item)
 
void ICollection< Num >. Add (Num item)
 
void ICollection< Num >. Clear ()
 
void ICollection< Num >. CopyTo (Num[] array, int arrayIndex)
 
bool ICollection< Num >. Remove (Num item)
 
bool Contains (Num item)
 
System.Collections.IEnumerator System.Collections.IEnumerable. GetEnumerator ()
 
IEnumerator< Num > IEnumerable< Num >. GetEnumerator ()
 
Enumerator GetEnumerator ()