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

Adapter: Provides access to a section of an array. More...


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

Remarks

Adapter: Provides access to a section of an array.

Public fields

T[] _list
 
int _start
 
int _count
 

Properties

int Count [get]
 
bool IsEmpty [get]
 
First [get, set]
 
Last [get, set]
 
this[int index] [get, set]
 
this[int index, T defaultValue] [get]
 
T[] InternalList [get]
 Returns the original array. More...
 
int InternalStart [get]
 
int InternalStop [get]
 
- Properties inherited from Loyc.Collections.IMRange< T >
new T this[int index] [get, set]
 
- Properties inherited from Loyc.Collections.IMBRange< T >
new T Last [get, set]
 Gets or sets the value of the last item in the range. More...
 
- Properties inherited from Loyc.Collections.IBRange< T >
Last [get]
 Returns the value of the last item in the range. More...
 
- Properties inherited from Loyc.Collections.IMFRange< T >
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...
 
- Properties inherited from Loyc.Collections.IIsEmpty
bool IsEmpty [get]
 

Public Member Functions

 ArraySlice (T[] list, int start, int count)
 Initializes an array slice. More...
 
 ArraySlice (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 ()
 
ArraySlice< T > ICloneable< ArraySlice< T > >. Clone ()
 
IEnumerator< T > IEnumerable< T >. GetEnumerator ()
 
System.Collections.IEnumerator System.Collections.IEnumerable. GetEnumerator ()
 
InternalList.Enumerator< T > GetEnumerator ()
 
TryGet (int index, out bool fail)
 
IRange< T > IListSource< T >. Slice (int start, int count)
 
ArraySlice< T > Slice (int start, int count=int.MaxValue)
 
T[] ToArray ()
 
- Public Member Functions inherited from Loyc.Collections.IBRange< T >
PopLast (out bool fail)
 Removes the last item from the range and returns it. More...
 
- Public Member Functions inherited from Loyc.Collections.IFRange< T >
PopFirst (out bool fail)
 Removes the first item from the range and returns it. More...
 

Static Public Member Functions

static implicit operator ArraySlice< T > (T[] array)
 

Constructor & Destructor Documentation

◆ ArraySlice()

Loyc.Collections.ArraySlice< T >.ArraySlice ( T[]  list,
int  start,
int  count 
)
inline

Initializes an array slice.

Exceptions
ArgumentExceptionThe start index was below zero.

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

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

Property Documentation

◆ InternalList

Returns the original array.

Ideally, to protect the array there would be no way to access its contents beyond the boundaries of the slice. However, the reality in .NET today is that many methods accept "slices" in the form of a triple (list, start index, count). In order to call such an old-style API using a slice, one must be able to extract the internal list and start index values.