Enhanced C#
Language of your choice: library documentation
Static Public Member Functions | List of all members
Loyc.Collections.LCExt Class Reference

Extension methods for Loyc Collection interfaces (such as IListSource<T>). More...


Source files:

Remarks

Extension methods for Loyc Collection interfaces (such as IListSource<T>).

The source code for adapter extension methods such as AsReadOnly() is now placed in the source file for each adapter class (e.g. CollectionAsReadOnly.cs) to make it easier to use parts of Loyc.Essentials rather than the entire library (other "decoupling" suggestions are welcome.)

Static Public Member Functions

static IListSource< T > AsListSource< T > (this IList< T > c)
 Adapter: treats any IList{T} object as IListSource{T}. More...
 
static IListSource< T > AsListSource< T > (this List< T > c)
 Adapter: treats List{T} as IListSource<T>. More...
 
static IListSource< T > AsListSource< T > (this T[] c)
 Adapter: treats T[] as IListSource<T>. More...
 
static IListSource< T > AsListSource< T > (this IListAndListSource< T > c)
 No-op. More...
 
static IList< T > AsList< T > (this IListSource< T > c)
 Converts any IListSource{T} object to a read-only IList{T}. More...
 
static ListSourceAsSparse< T > AsSparse< T > (this IListSource< T > list)
 Treats a non-sparse list as a read-only sparse list with no empty spaces. More...
 
static ISparseListSource< T > AsSparse< T > (this ISparseListSource< T > list)
 Returns list itself. This overload exists to prevent you from accidentally wrapping a sparse list in ListSourceAsSparse<T>, which would block access to knowledge of any empty spaces in the list. More...
 
static NegListSlice< T > Slice< T > (this INegListSource< T > list, int start, int count=int.MaxValue)
 
static NegListSource< T > AsNegList< T > (this IListSource< T > list, int zeroOffset)
 
static IListSource< T > AsListSource< T > (this IReadOnlyList< T > c)
 Adapter: treats any IReadOnlyList{T} object as IListSource{T}. More...
 
static IListSource< T > AsListSource< T > (this IListSource< T > c)
 No-op. More...
 
static ICollection< T > AsCollection< T > (this IReadOnlyCollection< T > c)
 Adapter: treats any IReadOnlyCollection{T} as a read-only ICollection{T}. More...
 
static IReadOnlyCollection< TResult > UpCast< T, TResult > (this IReadOnlyCollection< T > source)
 
static IListSource< TResult > UpCast< T, TResult > (this IListSource< T > source)
 
static string Join (this System.Collections.IEnumerable list, string separator)
 

Member Function Documentation

◆ AsCollection< T >()

static ICollection<T> Loyc.Collections.LCExt.AsCollection< T > ( this IReadOnlyCollection< T >  c)
inlinestatic

Adapter: treats any IReadOnlyCollection{T} as a read-only ICollection{T}.

This method is named "AsCollection" and not "ToCollection" because, in contrast to methods like ToArray() and ToList(), it does not make a copy of the sequence, although it does create a new wrapper object.

◆ AsList< T >()

static IList<T> Loyc.Collections.LCExt.AsList< T > ( this IListSource< T >  c)
inlinestatic

Converts any IListSource{T} object to a read-only IList{T}.

This method is named "AsList" and not "ToList" because because, in contrast to methods like ToArray(), it does not make a copy of the sequence, although it does create a new wrapper object if c does not implement IList<T>.

◆ AsListSource< T >() [1/6]

static IListSource<T> Loyc.Collections.LCExt.AsListSource< T > ( this IList< T >  c)
inlinestatic

Adapter: treats any IList{T} object as IListSource{T}.

This method is named "AsListSource" and not "ToListSource" because, in contrast to methods like ToArray() and ToList(), it does not make a copy of the sequence.

◆ AsListSource< T >() [2/6]

static IListSource<T> Loyc.Collections.LCExt.AsListSource< T > ( this IListAndListSource< T >  c)
static

No-op.

◆ AsListSource< T >() [3/6]

static IListSource<T> Loyc.Collections.LCExt.AsListSource< T > ( this IListSource< T >  c)
static

No-op.

◆ AsListSource< T >() [4/6]

static IListSource<T> Loyc.Collections.LCExt.AsListSource< T > ( this IReadOnlyList< T >  c)
inlinestatic

Adapter: treats any IReadOnlyList{T} object as IListSource{T}.

This method is named "AsListSource" and not "ToListSource" because, in contrast to methods like ToArray() and ToList(), it does not make a copy of the sequence.

◆ AsListSource< T >() [5/6]

static IListSource<T> Loyc.Collections.LCExt.AsListSource< T > ( this List< T >  c)
static

Adapter: treats List{T} as IListSource<T>.

◆ AsListSource< T >() [6/6]

static IListSource<T> Loyc.Collections.LCExt.AsListSource< T > ( this T[]  c)
static

Adapter: treats T[] as IListSource<T>.

◆ AsSparse< T >() [1/2]

static ListSourceAsSparse<T> Loyc.Collections.LCExt.AsSparse< T > ( this IListSource< T >  list)
inlinestatic

Treats a non-sparse list as a read-only sparse list with no empty spaces.

◆ AsSparse< T >() [2/2]

static ISparseListSource<T> Loyc.Collections.LCExt.AsSparse< T > ( this ISparseListSource< T >  list)
inlinestatic

Returns list itself. This overload exists to prevent you from accidentally wrapping a sparse list in ListSourceAsSparse<T>, which would block access to knowledge of any empty spaces in the list.