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

This class enhances LINQ-to-Objects with extension methods that preserve the interface (e.g. Take(IList<int>) returns a struct that implements IList<int>) or have higher performance than the ones in System.Linq.Enumerable. More...


Source files:

Remarks

This class enhances LINQ-to-Objects with extension methods that preserve the interface (e.g. Take(IList<int>) returns a struct that implements IList<int>) or have higher performance than the ones in System.Linq.Enumerable.

For example, the Enumerable.Last() extension method scans the entire list before returning the last item, while Last<T>(IReadOnlyList<T>) and Last<T>(IList<T>) simply return the last item directly.

Static Public Member Functions

static BufferedSequence< T > Buffered< T > (this IEnumerator< T > source)
 
static BufferedSequence< T > Buffered< T > (this IEnumerable< T > source)
 
static IListSource< T > Buffered< T > (this IListSource< T > source)
 
static BufferedSequence< T > Buffered< T > (this IList< T > source)
 
static int Count< T > (this IList< T > list)
 
static int Count< T > (this IReadOnlyCollection< T > list)
 
static int Count< T > (this INegListSource< T > list)
 
static T FirstOrDefault< T > (this IList< T > list, T defaultValue=default(T))
 
static T FirstOrDefault< T > (this IListSource< T > list)
 
static T FirstOrDefault< T > (this IListSource< T > list, T defaultValue)
 
static T FirstOrDefault< T > (this IListAndListSource< T > list, T defaultValue=default(T))
 
static T Last< T > (this IList< T > list)
 Gets the last item from the list (at list.Max). More...
 
static T LastOrDefault< T > (this IList< T > list, T defaultValue=default(T))
 Gets the last item from the list (Count - 1), or defaultValue if the list is empty. More...
 
static T Last< T > (this IReadOnlyList< T > list)
 Gets the last item from the list (at list.Max). More...
 
static T LastOrDefault< T > (this IReadOnlyList< T > list, T defaultValue=default(T))
 Gets the last item from the list (Count - 1), or defaultValue if the list is empty. More...
 
static T Last< T > (this IListAndListSource< T > list)
 
static T LastOrDefault< T > (this IListAndListSource< T > list, T defaultValue=default(T))
 
static T Last< T > (this INegListSource< T > list)
 Gets the last item from the list (at list.Max). More...
 
static T LastOrDefault< T > (this INegListSource< T > list, T defaultValue=default(T))
 Gets the last item from the list (at list.Max), or defaultValue if the list is empty. More...
 
static Slice_< T > Skip< T > (this IListSource< T > list, int start)
 Skips the specified number of elements immediately and returns a slice of part of the list that remains, or an empty slice if start is greater than or equal to the list.Count. More...
 
static Slice_< T > Take< T > (this IListSource< T > list, int count)
 Returns a slice of the specified number of elements from the beginning of the list, or a slice of the entire list if count is greater than or equal to the list.Count. More...
 
static ListSlice< T > Skip< T > (this IList< T > list, int start)
 Skips the specified number of elements immediately and returns a slice of part of the list that remains, or an empty slice if start is greater than or equal to the list.Count. More...
 
static ListSlice< T > Take< T > (this IList< T > list, int count)
 Returns a slice of the specified number of elements from the beginning of the list, or a slice of the entire list if count is greater than or equal to the list.Count. More...
 
static ListSlice< T > Skip< T > (this IListAndListSource< T > list, int start)
 Skips the specified number of elements immediately and returns a slice of part of the list that remains, or an empty slice if start is greater than or equal to the list.Count. More...
 
static ListSlice< T > Take< T > (this IListAndListSource< T > list, int count)
 Returns a slice of the specified number of elements from the beginning of the list, or a slice of the entire list if count is greater than or equal to the list.Count. More...
 
static NegListSlice< T > Skip< T > (this INegListSource< T > list, int count)
 
static NegListSlice< T > Take< T > (this INegListSource< T > list, int count)
 
static ListSlice< T > TakeNowWhile< T > (this IList< T > list, Func< T, bool > predicate)
 Returns a slice of the initial elements of the list that meet the provided criteria. The word "now" is added to the name because unlike Enumerable.TakeWhile, this method scans the list immediately. More...
 
static ListSlice< T > SkipNowWhile< T > (this IList< T > list, Func< T, bool > predicate)
 Returns a slice without the initial elements of the list that meet the specified criteria. The word "now" is added to the name because unlike Enumerable.SkipWhile, this method scans the list immediately. More...
 
static Slice_< T > TakeNowWhile< T > (this IListSource< T > list, Func< T, bool > predicate)
 Returns a slice of the initial elements of the list that meet the provided criteria. The word "now" is added to the name because unlike Enumerable.TakeWhile, this method scans the list immediately. More...
 
static Slice_< T > SkipNowWhile< T > (this IListSource< T > list, Func< T, bool > predicate)
 Returns a slice without the initial elements of the list that meet the specified criteria. The word "now" is added to the name because unlike Enumerable.SkipWhile, this method scans the list immediately. More...
 
static NegListSlice< T > TakeNowWhile< T > (this INegListSource< T > list, Func< T, bool > predicate)
 Returns a slice of the initial elements of the list that meet the provided criteria. The word "now" is added to the name because unlike Enumerable.TakeWhile, this method scans the list immediately. More...
 
static NegListSlice< T > SkipNowWhile< T > (this INegListSource< T > list, Func< T, bool > predicate)
 Returns a slice without the initial elements of the list that meet the specified criteria. The word "now" is added to the name because unlike Enumerable.SkipWhile, this method scans the list immediately. More...
 
static ListSlice< T > TakeNowWhile< T > (this IListAndListSource< T > list, Func< T, bool > predicate)
 
static ListSlice< T > SkipNowWhile< T > (this IListAndListSource< T > list, Func< T, bool > predicate)
 
static T[] ToArray< T > (this IReadOnlyList< T > c)
 Copies the contents of a list to an array. More...
 
static T[] ToArray< T > (this IList< T > c)
 Copies the contents of a list to an array. More...
 
static T[] ToArray< T > (this IListAndListSource< T > c)
 
static T[] ToArray< T > (this INegListSource< T > c)
 Copies the contents of an INegListSource<T> to an array. More...
 
static SelectListSource< T, TResult > Select< T, TResult > (this IListSource< T > source, Func< T, TResult > selector)
 
static SelectListSource< T, TResult > Select< T, TResult > (this IListAndListSource< T > source, Func< T, TResult > selector)
 
static SelectList< T, TResult > Select< T, TResult > (this IList< T > source, Func< T, TResult > selector)
 
static ReversedListSource< T > Reverse< T > (this IListSource< T > c)
 Returns a reversed view of a read-only list. More...
 
static ReversedList< T > Reverse< T > (this IList< T > list)
 Returns an editable reversed view of a list. More...
 
static ReversedList< T > Reverse< T > (this IListAndListSource< T > list)
 Returns an editable reversed view of a list. More...
 

Member Function Documentation

static T Loyc.Collections.LinqToLists.Last< T > ( this IList< T >  list)
inlinestatic

Gets the last item from the list (at list.Max).

Exceptions
EmptySequenceExceptionThe list is empty
static T Loyc.Collections.LinqToLists.Last< T > ( this IReadOnlyList< T >  list)
inlinestatic

Gets the last item from the list (at list.Max).

Exceptions
EmptySequenceExceptionThe list is empty
static T Loyc.Collections.LinqToLists.Last< T > ( this INegListSource< T >  list)
inlinestatic

Gets the last item from the list (at list.Max).

Exceptions
EmptySequenceExceptionThe list is empty
static T Loyc.Collections.LinqToLists.LastOrDefault< T > ( this IList< T >  list,
defaultValue = default(T) 
)
inlinestatic

Gets the last item from the list (Count - 1), or defaultValue if the list is empty.

static T Loyc.Collections.LinqToLists.LastOrDefault< T > ( this IReadOnlyList< T >  list,
defaultValue = default(T) 
)
inlinestatic

Gets the last item from the list (Count - 1), or defaultValue if the list is empty.

static T Loyc.Collections.LinqToLists.LastOrDefault< T > ( this INegListSource< T >  list,
defaultValue = default(T) 
)
inlinestatic

Gets the last item from the list (at list.Max), or defaultValue if the list is empty.

static ReversedListSource<T> Loyc.Collections.LinqToLists.Reverse< T > ( this IListSource< T >  c)
inlinestatic

Returns a reversed view of a read-only list.

This was originally named ReverseView. Changed to Reverse to match Linq's Reverse(IEnumerable).

static ReversedList<T> Loyc.Collections.LinqToLists.Reverse< T > ( this IList< T >  list)
inlinestatic

Returns an editable reversed view of a list.

This was originally named ReverseView. Changed to Reverse to match Linq's Reverse(IEnumerable).

static ReversedList<T> Loyc.Collections.LinqToLists.Reverse< T > ( this IListAndListSource< T >  list)
inlinestatic

Returns an editable reversed view of a list.

This was originally named ReverseView. Changed to Reverse to match Linq's Reverse(IEnumerable).

static Slice_<T> Loyc.Collections.LinqToLists.Skip< T > ( this IListSource< T >  list,
int  start 
)
inlinestatic

Skips the specified number of elements immediately and returns a slice of part of the list that remains, or an empty slice if start is greater than or equal to the list.Count.

static ListSlice<T> Loyc.Collections.LinqToLists.Skip< T > ( this IList< T >  list,
int  start 
)
inlinestatic

Skips the specified number of elements immediately and returns a slice of part of the list that remains, or an empty slice if start is greater than or equal to the list.Count.

static ListSlice<T> Loyc.Collections.LinqToLists.Skip< T > ( this IListAndListSource< T >  list,
int  start 
)
inlinestatic

Skips the specified number of elements immediately and returns a slice of part of the list that remains, or an empty slice if start is greater than or equal to the list.Count.

static ListSlice<T> Loyc.Collections.LinqToLists.SkipNowWhile< T > ( this IList< T >  list,
Func< T, bool >  predicate 
)
inlinestatic

Returns a slice without the initial elements of the list that meet the specified criteria. The word "now" is added to the name because unlike Enumerable.SkipWhile, this method scans the list immediately.

Example: new[] { 24, 28, 2, 12, 11 }.SkipNowWhile(n => n > 10) returns a slice (not a copy) of the last 2 elements.

static Slice_<T> Loyc.Collections.LinqToLists.SkipNowWhile< T > ( this IListSource< T >  list,
Func< T, bool >  predicate 
)
inlinestatic

Returns a slice without the initial elements of the list that meet the specified criteria. The word "now" is added to the name because unlike Enumerable.SkipWhile, this method scans the list immediately.

Example: new[] { 24, 28, 2, 12, 11 }.SkipNowWhile(n => n > 10) returns a slice (not a copy) of the last 2 elements.

static NegListSlice<T> Loyc.Collections.LinqToLists.SkipNowWhile< T > ( this INegListSource< T >  list,
Func< T, bool >  predicate 
)
inlinestatic

Returns a slice without the initial elements of the list that meet the specified criteria. The word "now" is added to the name because unlike Enumerable.SkipWhile, this method scans the list immediately.

Example: new[] { 24, 28, 2, 12, 11 }.SkipNowWhile(n => n > 10) returns a slice (not a copy) of the last 2 elements.

static Slice_<T> Loyc.Collections.LinqToLists.Take< T > ( this IListSource< T >  list,
int  count 
)
inlinestatic

Returns a slice of the specified number of elements from the beginning of the list, or a slice of the entire list if count is greater than or equal to the list.Count.

static ListSlice<T> Loyc.Collections.LinqToLists.Take< T > ( this IList< T >  list,
int  count 
)
inlinestatic

Returns a slice of the specified number of elements from the beginning of the list, or a slice of the entire list if count is greater than or equal to the list.Count.

static ListSlice<T> Loyc.Collections.LinqToLists.Take< T > ( this IListAndListSource< T >  list,
int  count 
)
inlinestatic

Returns a slice of the specified number of elements from the beginning of the list, or a slice of the entire list if count is greater than or equal to the list.Count.

static ListSlice<T> Loyc.Collections.LinqToLists.TakeNowWhile< T > ( this IList< T >  list,
Func< T, bool >  predicate 
)
inlinestatic

Returns a slice of the initial elements of the list that meet the provided criteria. The word "now" is added to the name because unlike Enumerable.TakeWhile, this method scans the list immediately.

Example: new[] { 13, 16, 19, 2, 11, 12 }.TakeNowWhile(n => n > 10) returns a slice (not a copy) of the first 3 elements.

static Slice_<T> Loyc.Collections.LinqToLists.TakeNowWhile< T > ( this IListSource< T >  list,
Func< T, bool >  predicate 
)
inlinestatic

Returns a slice of the initial elements of the list that meet the provided criteria. The word "now" is added to the name because unlike Enumerable.TakeWhile, this method scans the list immediately.

Example: new[] { 13, 16, 19, 2, 11, 12 }.TakeNowWhile(n => n > 10) returns a slice (not a copy) of the first 3 elements.

static NegListSlice<T> Loyc.Collections.LinqToLists.TakeNowWhile< T > ( this INegListSource< T >  list,
Func< T, bool >  predicate 
)
inlinestatic

Returns a slice of the initial elements of the list that meet the provided criteria. The word "now" is added to the name because unlike Enumerable.TakeWhile, this method scans the list immediately.

Example: new[] { 13, 16, 19, 2, 11, 12 }.TakeNowWhile(n => n > 10) returns a slice (not a copy) of the first 3 elements.

static T [] Loyc.Collections.LinqToLists.ToArray< T > ( this IReadOnlyList< T >  c)
inlinestatic

Copies the contents of a list to an array.

static T [] Loyc.Collections.LinqToLists.ToArray< T > ( this IList< T >  c)
inlinestatic

Copies the contents of a list to an array.

static T [] Loyc.Collections.LinqToLists.ToArray< T > ( this INegListSource< T >  c)
inlinestatic

Copies the contents of an INegListSource<T> to an array.