Enhanced C#
Language of your choice: library documentation
Public fields | Public static fields | Properties | Public Member Functions | List of all members
Loyc.Collections.Slice_< T > Struct Template Reference

Adapter: a random-access range for a slice of an IListSource<T>. More...


Source file:
Inheritance diagram for Loyc.Collections.Slice_< T >:
Loyc.Collections.IRange< T > Loyc.Collections.IIsEmpty

Remarks

Adapter: a random-access range for a slice of an IListSource<T>.

Template Parameters
TItem type in the list

This type was supposed to be called simply Slice, but this was not allowed because in plain C#, "CS0542: member names cannot be the same as their enclosing type" and of course, this type contains the Slice() method from IListSource.

Public fields

IListSource< T > _list
 
int _start
 
int _count
 

Public static fields

static readonly Slice_< T > Empty = new Slice_<T>()
 

Properties

int Count [get]
 
bool IsEmpty [get]
 
First [get]
 
Last [get]
 
this[int index] [get]
 
T? this[int index, T defaultValue] [get]
 
- Properties inherited from Loyc.Collections.IIsEmpty
bool IsEmpty [get]
 

Public Member Functions

 Slice_ (IListSource< T > list, int start, int count=int.MaxValue)
 Initializes a slice. More...
 
 Slice_ (IListSource< T > list)
 
PopFirst (out bool empty)
 
PopLast (out bool empty)
 
IFRange< T > ICloneable< IFRange< T > >. Clone ()
 
IBRange< T > ICloneable< IBRange< T > >. Clone ()
 
IRange< T > ICloneable< IRange< T > >. Clone ()
 
Slice_< T > Clone ()
 
IEnumerator< T > IEnumerable< T >. GetEnumerator ()
 
System.Collections.IEnumerator System.Collections.IEnumerable. GetEnumerator ()
 
RangeEnumerator< Slice_< T >, T > GetEnumerator ()
 
TryGet (int index, out bool fail)
 
IRange< T > IListSource< T >. Slice (int start, int count)
 
Slice_< T > Slice (int start, int count=int.MaxValue)
 

Constructor & Destructor Documentation

◆ Slice_()

Loyc.Collections.Slice_< T >.Slice_ ( IListSource< T >  list,
int  start,
int  count = int.MaxValue 
)
inline

Initializes a slice.

Exceptions
ArgumentExceptionThe start index was below zero.

The (start, count) range is allowed to be invalid, as long as 'start' and 'count' are zero or above.

  • If 'start' is above the original Count, the Count of the new slice is set to zero.
  • if (start + count) is above the original Count, the Count of the new slice is reduced to list.Count - start.