Enhanced C#
Language of your choice: library documentation
Properties | List of all members
Loyc.Collections.IMFRange< T > Interface Template Reference

A mutable forward range. More...

Source file:
Inheritance diagram for Loyc.Collections.IMFRange< T >:
Loyc.Collections.IFRange< T > Loyc.Collections.IMBRange< T > Loyc.Collections.IMRange< T > Loyc.Collections.ArraySlice< T >


A mutable forward range.

This range lets you change the value of First.

Please see IFRange<T> for general documentation about ranges.

The mutable ranges do not include a clone method due to a limitation of C#. C# does not support covariance, which means that every time a derived interface supports cloning, the implementing class is required to write a separate clone method. Read-only ranges already have to implement up to four clone methods: ICloneable{IFRange{T}}, ICloneable{IBRange{T}}, ICloneable{IRange{T}}, and ICloneable{IRangeEx{T}}, and that's in addition to the Clone method for the concrete type! If mutable ranges also supported cloning, they would add up to three more clone methods, which is really getting out of hand.

To limit the maximum number of clone methods to something reasonable, only the immutable ranges have a clone method, but if the original range was mutable then the clone will also be mutable; you just have to cast the result:

var r2 = (IMFRange<T>)r.Clone();


new T First [get, set]
 Gets or sets the value of the first item in the range. More...
- Properties inherited from Loyc.Collections.IFRange< T >
First [get]
 Returns the first value in the range, without popping it. More...

Additional Inherited Members

- Public Member Functions inherited from Loyc.Collections.IFRange< T >
PopFirst (out bool fail)
 Removes the first item from the range and returns it. More...

Property Documentation

◆ First

new T Loyc.Collections.IMFRange< T >.First

Gets or sets the value of the first item in the range.

EmptySequenceExceptionThe sequence is empty.