Show / Hide Table of Contents

    Class ListExtensions

    Inheritance
    System.Object
    ListExtensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Lucene.Net.Support
    Assembly: Lucene.Net.dll
    Syntax
    public static class ListExtensions

    Methods

    | Improve this Doc View Source

    AddRange<T>(IList<T>, IEnumerable<T>)

    Declaration
    public static void AddRange<T>(this IList<T> list, IEnumerable<T> values)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list
    System.Collections.Generic.IEnumerable<T> values
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    BinarySearch<T>(IList<T>, T)

    Performs a binary search for the specified element in the specified sorted list. The list needs to be already sorted in natural sorting order. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

    Declaration
    public static int BinarySearch<T>(this IList<T> list, T item)
    
        where T : IComparable<T>
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    The sorted list to search.

    T item

    The element to find.

    Returns
    Type Description
    System.Int32

    The non-negative index of the element, or a negative index which is the -index - 1 where the element would be inserted.

    Type Parameters
    Name Description
    T

    The element type.

    Exceptions
    Type Condition
    System.InvalidCastException

    If an element in the List or the search element does not implement System.IComparable<T>, or cannot be compared to each other.

    | Improve this Doc View Source

    BinarySearch<T>(IList<T>, T, IComparer<T>)

    Performs a binary search for the specified element in the specified sorted list using the specified comparator. The list needs to be already sorted according to the comparer passed. Searching in an unsorted array has an undefined result. It's also undefined which element is found if there are multiple occurrences of the same element.

    Declaration
    public static int BinarySearch<T>(this IList<T> list, T item, IComparer<T> comparer)
    
        where T : IComparable<T>
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    The sorted System.Collections.Generic.IList<T> to search.

    T item

    The element to find.

    System.Collections.Generic.IComparer<T> comparer

    The comparer. If the comparer is null then the search uses the objects' natural ordering.

    Returns
    Type Description
    System.Int32

    the non-negative index of the element, or a negative index which is the -index - 1 where the element would be inserted.

    Type Parameters
    Name Description
    T

    The element type.

    Exceptions
    Type Condition
    System.InvalidCastException

    when an element in the list and the searched element cannot be compared to each other using the comparer.

    | Improve this Doc View Source

    IntroSort<T>(IList<T>)

    Sorts the given System.Collections.Generic.IList<T> using the System.Collections.Generic.IComparer<T>. This method uses the intro sort algorithm, but falls back to insertion sort for small lists.

    Declaration
    public static void IntroSort<T>(this IList<T> list)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    this System.Collections.Generic.IList<T>

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    IntroSort<T>(IList<T>, IComparer<T>)

    Sorts the given System.Collections.Generic.IList<T> using the System.Collections.Generic.IComparer<T>. This method uses the intro sort algorithm, but falls back to insertion sort for small lists.

    Declaration
    public static void IntroSort<T>(this IList<T> list, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    this System.Collections.Generic.IList<T>

    System.Collections.Generic.IComparer<T> comparer

    The System.Collections.Generic.IComparer<T> to use for the sort.

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Shuffle<T>(IList<T>)

    Shuffles an System.Collections.Generic.IList<T> in place using a new System.Random instance.

    Declaration
    public static void Shuffle<T>(this IList<T> list)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    This System.Collections.Generic.IList<T>.

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Shuffle<T>(IList<T>, Random)

    Shuffles an System.Collections.Generic.IList<T> in place using the specified random instance.

    Declaration
    public static void Shuffle<T>(this IList<T> list, Random random)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    This System.Collections.Generic.IList<T>.

    System.Random random
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Sort<T>(IList<T>)

    If the underlying type is System.Collections.Generic.List<T>, calls System.Collections.Generic.List`1.Sort. If not, uses TimSort<T>(IList<T>)

    Declaration
    public static void Sort<T>(this IList<T> list)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    this System.Collections.Generic.IList<T>

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Sort<T>(IList<T>, IComparer<T>)

    If the underlying type is System.Collections.Generic.List<T>, calls System.Collections.Generic.List`1.Sort(System.Collections.Generic.IComparer{`0}). If not, uses TimSort<T>(IList<T>, IComparer<T>)

    Declaration
    public static void Sort<T>(this IList<T> list, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    this System.Collections.Generic.IList<T>

    System.Collections.Generic.IComparer<T> comparer

    the comparer to use for the sort

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Sort<T>(IList<T>, Comparison<T>)

    If the underlying type is System.Collections.Generic.List<T>, calls System.Collections.Generic.List`1.Sort(System.Collections.Generic.IComparer{`0}). If not, uses TimSort<T>(IList<T>, IComparer<T>)

    Declaration
    public static void Sort<T>(this IList<T> list, Comparison<T> comparison)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    this System.Collections.Generic.IList<T>

    System.Comparison<T> comparison

    the comparison function to use for the sort

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    SubList<T>(IList<T>, Int32, Int32)

    Declaration
    public static IList<T> SubList<T>(this IList<T> list, int fromIndex, int toIndex)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list
    System.Int32 fromIndex
    System.Int32 toIndex
    Returns
    Type Description
    System.Collections.Generic.IList<T>
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Swap<T>(IList<T>, Int32, Int32)

    Declaration
    public static void Swap<T>(this IList<T> list, int indexA, int indexB)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list
    System.Int32 indexA
    System.Int32 indexB
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    TimSort<T>(IList<T>)

    Sorts the given System.Collections.Generic.IList<T> using the System.Collections.Generic.IComparer<T>. This method uses the Tim sort algorithm, but falls back to binary sort for small lists.

    Declaration
    public static void TimSort<T>(this IList<T> list)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    this System.Collections.Generic.IList<T>

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    TimSort<T>(IList<T>, IComparer<T>)

    Sorts the given System.Collections.Generic.IList<T> using the System.Collections.Generic.IComparer<T>. This method uses the Tim sort algorithm, but falls back to binary sort for small lists.

    Declaration
    public static void TimSort<T>(this IList<T> list, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> list

    this System.Collections.Generic.IList<T>

    System.Collections.Generic.IComparer<T> comparer

    The System.Collections.Generic.IComparer<T> to use for the sort.

    Type Parameters
    Name Description
    T
    • Improve this Doc
    • View Source
    Back to top Copyright © 2019 Licensed to the Apache Software Foundation (ASF)