Enhanced C#
Language of your choice: library documentation
Public Member Functions | List of all members
Loyc.Collections.ICollectionSource< T > Interface Template Reference

A variation of IReadOnlyCollection that provides the Contains() and CopyTo() methods from ICollection. More...


Source file:
Inheritance diagram for Loyc.Collections.ICollectionSource< T >:
Loyc.Collections.IContains< T > Loyc.Collections.ICollectionAndSource< T > Loyc.Collections.ICollectionImpl< T > Loyc.Collections.ISetImm< T > Loyc.Collections.IListAndListSource< T > Loyc.Collections.ICollectionEx< T > Loyc.Collections.AListBase< K, T > Loyc.Collections.FVList< T > Loyc.Collections.FWList< T > Loyc.Collections.IListEx< T > Loyc.Collections.IListWithChangeEvents< T > Loyc.Collections.Impl.InternalList< T > Loyc.Collections.Impl.ListSourceBase< T > Loyc.Collections.Impl.ListWrapper< T, TList > Loyc.Collections.ISparseList< T > Loyc.Collections.ListAsListSource< T > Loyc.Collections.ListSlice< T > Loyc.Collections.ListSourceAsList< T > Loyc.Collections.Repeated< T > Loyc.Collections.VList< T > Loyc.Collections.WList< T > Loyc.Collections.WListBase< T > Loyc.Collections.BList< T > Loyc.Collections.ICollectionExWithChangeEvents< T > Loyc.Collections.IListEx< T > Loyc.Collections.ListSlice< T >

Remarks

A variation of IReadOnlyCollection that provides the Contains() and CopyTo() methods from ICollection.

Implementing this interface suggests that the collection may support accelerated membership tests (int O(1) or O(log(Count)) time), because if it doesn't, the collection only needs to implement IReadOnlyCollection (relying on extension methods for Contains() and CopyTo()).

The name of this collection fits a pattern: just as IListSource is a variation on IReadOnlyList with additional functionality, this interface is a variation on IReadOnlyCollection with additional functionality. The word "source" means "data comes out"; it is the opposite of a "sink" which means "data goes in".

Public Member Functions

void CopyTo (T[] array, int arrayIndex)
 Copies the elements of the collection to an Array, starting at a particular array index. More...
 
- Public Member Functions inherited from Loyc.Collections.IContains< T >
bool Contains (T item)
 Returns true if and only if the collection contains the specified item. More...
 

Member Function Documentation

◆ CopyTo()

void Loyc.Collections.ICollectionSource< T >.CopyTo ( T[]  array,
int  arrayIndex 
)

Copies the elements of the collection to an Array, starting at a particular array index.

It's usually more convenient to call the ToArray() extension method, which calls this method for you.

This method exists for performance reasons (the collection itself can often copy data out faster than an enumerator can).

Exceptions
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeExceptionarrayIndex is negative.
ArgumentExceptionThe number of elements in the source collection is greater than the available space from arrayIndex to the end of the destination array.

Implemented in Loyc.Collections.AListBase< K, T >, Loyc.Collections.FVList< T >, Loyc.Collections.VList< T >, Loyc.Collections.WListBase< T >, Loyc.Collections.Impl.InternalList< T >, Loyc.Collections.ListSlice< T >, Loyc.Collections.DList< T >, Loyc.Collections.Repeated< T >, Loyc.Collections.Repeated< T >, Loyc.Collections.ListAsListSource< T >, Loyc.Collections.ReversedList< T >, Loyc.Collections.ListSourceAsList< T >, and Loyc.Collections.Impl.ListExBase< T >.

Referenced by Loyc.Collections.CollectionSource.ToArray< T >().