|
Enhanced C#
Language of your choice: library documentation
|
Helper struct: enumerates through a forward range (IFRange{T}), calling the range methods through R instead of through IFRange{T}. More...
Helper struct: enumerates through a forward range (IFRange{T}), calling the range methods through R instead of through IFRange{T}.
Although there is a ICloneable{R} constraint on R, it is currently worthless due to a limitation of C#. Since IFRange{T} already includes ICloneable(IFRange(T)), this structure cannot simply invoke Clone() directly because the compiler complains that Clone() is ambiguous. Consequently it is necessary to cast the range to ICloneable{R} just to clone it; if R is a value type then it is boxed, which defeats the entire performance advantage of calling ICloneable{R}.Clone() instead of ICloneable{IFRange{T}}.Clone.
Nevertheless, I have left the constraint in place, in the hope that EC# can eventually eliminate this limitation thanks to its "using" cast. Once EC# compiles directly to CIL, range(using ICloneable<R>).Clone() will not perform boxing.
| R | : | IFRange<T> | |
| R | : | ICloneable<R> |
Public fields | |
| R | _range |
| T | _current |
Properties | |
| T | Current [get] |
|
object System.Collections.IEnumerator. | Current [get] |
Public Member Functions | |
| RangeEnumerator (R range) | |
| bool | MoveNext () |
| void IDisposable. | Dispose () |
|
void System.Collections.IEnumerator. | Reset () |
1.8.7