Options
All
  • Public
  • Public/Protected
  • All
Menu

Class List<T>

LinQ to TypeScript

Documentation from LinQ .NET specification (https://msdn.microsoft.com/en-us/library/system.linq.enumerable.aspx)

Created by Flavio Corpa (@kutyel) Copyright © 2016 Flavio Corpa. All rights reserved.

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

  • new List(elements?: T[]): List
  • Defaults the elements of the list

    Parameters

    • Optional elements: T[]

    Returns List

Properties

Protected _elements

_elements: T[]

Methods

Add

  • Add(element: T): void
  • Adds an object to the end of the List.

    Parameters

    • element: T

    Returns void

AddRange

  • AddRange(elements: T[]): void
  • Adds the elements of the specified collection to the end of the List.

    Parameters

    • elements: T[]

    Returns void

Aggregate

  • Aggregate<U>(accumulator: function, initialValue?: U): any
  • Applies an accumulator function over a sequence.

    Type parameters

    • U

    Parameters

    • accumulator: function
        • (accum: U, value?: T, index?: number, list?: T[]): any
        • Parameters

          • accum: U
          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns any

    • Optional initialValue: U

    Returns any

All

  • All(predicate: function): boolean
  • Determines whether all elements of a sequence satisfy a condition.

    Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns boolean

Any

  • Any(predicate: function): boolean
  • Determines whether a sequence contains any elements.

    Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns boolean

Average

  • Average(transform?: function): number
  • Computes the average of a sequence of number values that are obtained by invoking a transform function on each element of the input sequence.

    Parameters

    • Optional transform: function
        • (value?: T, index?: number, list?: T[]): any
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns any

    Returns number

Concat

  • Concatenates two sequences.

    Parameters

    Returns List<T>

Contains

  • Contains(element: T): boolean
  • Determines whether an element is in the List.

    Parameters

    • element: T

    Returns boolean

Count

  • Count(): number
  • Count(predicate: function): number
  • Returns the number of elements in a sequence.

    Returns number

  • Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns number

DefaultIfEmpty

  • DefaultIfEmpty(defaultValue?: T): List<T>
  • Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.

    Parameters

    • Optional defaultValue: T

    Returns List<T>

Distinct

  • Distinct(): List<T>
  • Returns distinct elements from a sequence by using the default equality comparer to compare values.

    Returns List<T>

ElementAt

  • ElementAt(index: number): T
  • Returns the element at a specified index in a sequence.

    Parameters

    • index: number

    Returns T

ElementAtOrDefault

  • ElementAtOrDefault(index: number): T
  • Returns the element at a specified index in a sequence or a default value if the index is out of range.

    Parameters

    • index: number

    Returns T

Except

  • Produces the set difference of two sequences by using the default equality comparer to compare values.

    Parameters

    Returns List<T>

First

  • First(): T
  • First(predicate: function): T
  • Returns the first element of a sequence.

    Returns T

  • Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns T

FirstOrDefault

  • FirstOrDefault(): T
  • FirstOrDefault(predicate: function): T
  • Returns the first element of a sequence, or a default value if the sequence contains no elements.

    Returns T

  • Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns T

ForEach

  • ForEach(action: function): void
  • Performs the specified action on each element of the List.

    Parameters

    • action: function
        • (value?: T, index?: number, list?: T[]): any
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns any

    Returns void

GroupBy

  • GroupBy(grouper: function, mapper: function): any
  • Groups the elements of a sequence according to a specified key selector function.

    Parameters

    • grouper: function
        • (key: T): any
        • Parameters

          • key: T

          Returns any

    • mapper: function
        • (element: T): any
        • Parameters

          • element: T

          Returns any

    Returns any

GroupJoin

  • GroupJoin<U>(list: List<U>, key1: function, key2: function, result: function): List<any>
  • Correlates the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys.

    Type parameters

    • U

    Parameters

    • list: List<U>
    • key1: function
        • (k: T): any
        • Parameters

          • k: T

          Returns any

    • key2: function
        • (k: U): any
        • Parameters

          • k: U

          Returns any

    • result: function
        • (first: T, second: List<U>): any
        • Parameters

          • first: T
          • second: List<U>

          Returns any

    Returns List<any>

Intersect

  • Produces the set intersection of two sequences by using the default equality comparer to compare values.

    Parameters

    Returns List<T>

Join

  • Join<U>(list: List<U>, key1: function, key2: function, result: function): List<any>
  • Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys.

    Type parameters

    • U

    Parameters

    • list: List<U>
    • key1: function
        • (key: T): any
        • Parameters

          • key: T

          Returns any

    • key2: function
        • (key: U): any
        • Parameters

          • key: U

          Returns any

    • result: function
        • (first: T, second: U): any
        • Parameters

          • first: T
          • second: U

          Returns any

    Returns List<any>

Last

  • Last(): T
  • Last(predicate: function): T
  • Returns the last element of a sequence.

    Returns T

  • Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns T

LastOrDefault

  • LastOrDefault(): T
  • LastOrDefault(predicate: function): T
  • Returns the last element of a sequence, or a default value if the sequence contains no elements.

    Returns T

  • Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns T

Max

  • Max(): T
  • Returns the maximum value in a generic sequence.

    Returns T

Min

  • Min(): T
  • Returns the minimum value in a generic sequence.

    Returns T

OrderBy

  • OrderBy(comparator: function): List<T>
  • Sorts the elements of a sequence in ascending order according to a key.

    Parameters

    • comparator: function
        • (key: T): any
        • Parameters

          • key: T

          Returns any

    Returns List<T>

OrderByDescending

  • OrderByDescending(comparator: function): List<T>
  • Sorts the elements of a sequence in descending order according to a key.

    Parameters

    • comparator: function
        • (key: T): any
        • Parameters

          • key: T

          Returns any

    Returns List<T>

Reverse

  • Reverse(): List<T>
  • Reverses the order of the elements in the entire List.

    Returns List<T>

Select

  • Select(mapper: function): List<any>
  • Projects each element of a sequence into a new form.

    Parameters

    • mapper: function
        • (value?: T, index?: number, list?: T[]): any
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns any

    Returns List<any>

SelectMany

  • SelectMany(mapper: function): List<any>
  • Projects each element of a sequence to a List and flattens the resulting sequences into one sequence.

    Parameters

    • mapper: function
        • (value?: T, index?: number, list?: T[]): any
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns any

    Returns List<any>

SequenceEqual

  • SequenceEqual(list: List<T>): boolean
  • Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.

    Parameters

    Returns boolean

Single

  • Single(): T | TypeError
  • Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

    Returns T | TypeError

SingleOrDefault

  • SingleOrDefault(): T | TypeError
  • Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

    Returns T | TypeError

Skip

  • Skip(amount: number): List<T>
  • Bypasses a specified number of elements in a sequence and then returns the remaining elements.

    Parameters

    • amount: number

    Returns List<T>

SkipWhile

  • SkipWhile(predicate: function): List<T>
  • Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.

    Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns List<T>

Sum

  • Sum(): number
  • Sum(transform: function): number
  • Computes the sum of the sequence of number values that are obtained by invoking a transform function on each element of the input sequence.

    Returns number

  • Parameters

    • transform: function
        • (value?: T, index?: number, list?: T[]): number
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns number

    Returns number

Take

  • Take(amount: number): List<T>
  • Returns a specified number of contiguous elements from the start of a sequence.

    Parameters

    • amount: number

    Returns List<T>

TakeWhile

  • TakeWhile(predicate: function): List<T>
  • Returns elements from a sequence as long as a specified condition is true.

    Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns List<T>

ThenBy

  • ThenBy(comparator: function): List<T>
  • Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.

    Parameters

    • comparator: function
        • (key: T): any
        • Parameters

          • key: T

          Returns any

    Returns List<T>

ThenByDescending

  • ThenByDescending(comparator: function): List<T>
  • Performs a subsequent ordering of the elements in a sequence in descending order, according to a key.

    Parameters

    • comparator: function
        • (key: T): any
        • Parameters

          • key: T

          Returns any

    Returns List<T>

ToArray

  • ToArray(): T[]
  • Copies the elements of the List to a new array.

    Returns T[]

ToDictionary

  • ToDictionary<TKey, TValue>(key: function, value?: function): any
  • Creates a Dictionary from a List according to a specified key selector function.

    Type parameters

    • TKey

    • TValue

    Parameters

    • key: function
        • (key: any): TKey
        • Parameters

          • key: any

          Returns TKey

    • Optional value: function
        • (value: any): TValue
        • Parameters

          • value: any

          Returns TValue

    Returns any

ToList

  • Creates a List from an Enumerable.List.

    Returns List<T>

Union

  • Produces the set union of two sequences by using the default equality comparer.

    Parameters

    Returns List<T>

Where

  • Where(predicate: function): List<T>
  • Filters a sequence of values based on a predicate.

    Parameters

    • predicate: function
        • (value?: T, index?: number, list?: T[]): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional list: T[]

          Returns boolean

    Returns List<T>

Zip

  • Zip<U>(list: List<U>, result: function): List<any>
  • Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.

    Type parameters

    • U

    Parameters

    • list: List<U>
    • result: function
        • (first: T, second: U): any
        • Parameters

          • first: T
          • second: U

          Returns any

    Returns List<any>

Generated using TypeDoc