Show / Hide Table of Contents

    Interface ISorted<T>

    A sorted collection, i.e. a collection where items are maintained and can be searched for in sorted order. Thus the sequence order is given as a sorting order.

    The sorting order is defined by a comparer, an object of type IComparer<T> (C5.IComparer`1). Implementors of this interface will normally let the user define the comparer as an argument to a constructor. Usually there will also be constructors without a comparer argument, in which case the comparer should be the defalt comparer for the item type, C5.Comparer`1.Default.

    The comparer of the sorted collection is available as the

    System.Collections.Generic.Comparer
    property (C5.ISorted`1.Comparer).

    The methods are grouped according to

    Since this interface extends ISequenced<T>, sorted collections will also have an item equalityComparer (C5.IExtensible`1.EqualityComparer). This equalityComparer will not be used in connection with the inner workings of the sorted collection, but will be used if the sorted collection is used as an item in a collection of unsequenced or sequenced collections, (C5.ICollection`1 and C5.ISequenced`1)

    Note that code may check if two sorted collections has the same sorting order by checking if the Comparer properties are equal. This is done a few places in this library for optimization purposes.

    Inherited Members
    ISequenced<T>.GetSequencedHashCode()
    ISequenced<T>.SequencedEquals(ISequenced<T>)
    ICollection<T>.ContainsSpeed
    ICollection<T>.Count
    ICollection<T>.IsReadOnly
    ICollection<T>.Add(T)
    ICollection<T>.CopyTo(T[], Int32)
    ICollection<T>.GetUnsequencedHashCode()
    ICollection<T>.UnsequencedEquals(ICollection<T>)
    ICollection<T>.Contains(T)
    ICollection<T>.ContainsCount(T)
    ICollection<T>.UniqueItems()
    ICollection<T>.ItemMultiplicities()
    ICollection<T>.ContainsAll(System.Collections.Generic.IEnumerable<T>)
    ICollection<T>.Find(T)
    ICollection<T>.FindOrAdd(T)
    ICollection<T>.Update(T)
    ICollection<T>.Update(T, T)
    ICollection<T>.UpdateOrAdd(T)
    ICollection<T>.UpdateOrAdd(T, T)
    ICollection<T>.Remove(T)
    ICollection<T>.Remove(T, T)
    ICollection<T>.RemoveAllCopies(T)
    ICollection<T>.RemoveAll(System.Collections.Generic.IEnumerable<T>)
    ICollection<T>.Clear()
    ICollection<T>.RetainAll(System.Collections.Generic.IEnumerable<T>)
    IExtensible<T>.AllowsDuplicates
    IExtensible<T>.EqualityComparer
    IExtensible<T>.DuplicatesByCounting
    IExtensible<T>.AddAll(System.Collections.Generic.IEnumerable<T>)
    IExtensible<T>.Check()
    IDirectedCollectionValue<T>.Backwards()
    IDirectedCollectionValue<T>.FindLast(Func<T, Boolean>, T)
    ICollectionValue<T>.ListenableEvents
    ICollectionValue<T>.ActiveEvents
    ICollectionValue<T>.CollectionChanged
    ICollectionValue<T>.CollectionCleared
    ICollectionValue<T>.ItemsAdded
    ICollectionValue<T>.ItemInserted
    ICollectionValue<T>.ItemsRemoved
    ICollectionValue<T>.ItemRemovedAt
    ICollectionValue<T>.IsEmpty
    ICollectionValue<T>.CountSpeed
    ICollectionValue<T>.ToArray()
    ICollectionValue<T>.Apply(Action<T>)
    ICollectionValue<T>.Exists(Func<T, Boolean>)
    ICollectionValue<T>.Find(Func<T, Boolean>, T)
    ICollectionValue<T>.All(Func<T, Boolean>)
    ICollectionValue<T>.Choose()
    ICollectionValue<T>.Filter(Func<T, Boolean>)
    IShowable.Show(System.Text.StringBuilder, Int32, IFormatProvider)
    IDirectedEnumerable<T>.Direction
    Namespace: Lucene.Net.Support.C5
    Assembly: Lucene.Net.dll
    Syntax
    public interface ISorted<T> : ISequenced<T>, ICollection<T>, IExtensible<T>, System.Collections.Generic.ICollection<T>, IDirectedCollectionValue<T>, ICollectionValue<T>, IShowable, IFormattable, IDirectedEnumerable<T>, System.Collections.Generic.IEnumerable<T>
    Type Parameters
    Name Description
    T

    Properties

    | Improve this Doc View Source

    Comparer

    The comparer object supplied at creation time for this sorted collection.

    Declaration
    System.Collections.Generic.IComparer<T> Comparer { get; }
    Property Value
    Type Description
    System.Collections.Generic.IComparer<T>

    The comparer

    Methods

    | Improve this Doc View Source

    AddSorted(System.Collections.Generic.IEnumerable<T>)

    Add all the items from another collection with an enumeration order that is increasing in the items.

    Declaration
    void AddSorted(System.Collections.Generic.IEnumerable<T> items)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> items

    The collection to add.

    | Improve this Doc View Source

    Cut(IComparable<T>, out T, out Boolean, out T, out Boolean)

    Given a "cut" function from the items of the sorted collection to

    int
    whose only sign changes when going through items in increasing order can be

    The "cut" function is supplied as the

    CompareTo
    method of an object
    c
    implementing

    IComparable<T>
    .

    A typical example is the case where

    T
    is comparable and

    cutFunction
    is itself of type
    T
    .

    This method performs a search in the sorted collection for the ranges in which the "cut" function is negative, zero respectively positive. If

    T
    is comparable and
    c
    is of type
    T
    , this is a safe way (no exceptions thrown) to find predecessor and successor of
    c
    .

    If the supplied cut function does not satisfy the sign-change condition, the result of this call is undefined.

    Declaration
    bool Cut(IComparable<T> cutFunction, out T low, out bool lowIsValid, out T high, out bool highIsValid)
    Parameters
    Type Name Description
    IComparable<T> cutFunction

    The cut function

    T
    to
    int
    , given by the
    CompareTo
    method of an object implementing

    IComparable<T>
    .
    T low

    Returns the largest item in the collection, where the cut function is positive (if any).

    System.Boolean lowIsValid

    Returns true if the cut function is positive somewhere on this collection.

    T high

    Returns the least item in the collection, where the cut function is negative (if any).

    System.Boolean highIsValid

    Returns true if the cut function is negative somewhere on this collection.

    Returns
    Type Description
    System.Boolean

    True if the cut function is zero somewhere on this collection.

    | Improve this Doc View Source

    DeleteMax()

    Remove the largest item from this sorted collection.

    Declaration
    T DeleteMax()
    Returns
    Type Description
    T

    The removed item.

    Exceptions
    Type Condition
    NoSuchItemException

    if the collection is empty.

    | Improve this Doc View Source

    DeleteMin()

    Remove the least item from this sorted collection.

    Declaration
    T DeleteMin()
    Returns
    Type Description
    T

    The removed item.

    Exceptions
    Type Condition
    NoSuchItemException

    if the collection is empty.

    | Improve this Doc View Source

    FindMax()

    Find the current largest item of this sorted collection.

    Declaration
    T FindMax()
    Returns
    Type Description
    T

    The largest item.

    Exceptions
    Type Condition
    NoSuchItemException

    if the collection is empty.

    | Improve this Doc View Source

    FindMin()

    Find the current least item of this sorted collection.

    Declaration
    T FindMin()
    Returns
    Type Description
    T

    The least item.

    Exceptions
    Type Condition
    NoSuchItemException

    if the collection is empty.

    | Improve this Doc View Source

    Predecessor(T)

    Find the strict predecessor in the sorted collection of a particular value, that is, the largest item in the collection less than the supplied value.

    Declaration
    T Predecessor(T item)
    Parameters
    Type Name Description
    T item

    The item to find the predecessor for.

    Returns
    Type Description
    T

    The predecessor.

    Exceptions
    Type Condition
    NoSuchItemException

    if no such element exists (the supplied value is less than or equal to the minimum of this collection.)

    | Improve this Doc View Source

    RangeAll()

    Create a directed collection with the same items as this collection.

    The returned collection is not a copy but a view into the collection.

    The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

    Declaration
    IDirectedCollectionValue<T> RangeAll()
    Returns
    Type Description
    IDirectedCollectionValue<T>

    The result directed collection.

    | Improve this Doc View Source

    RangeFrom(T)

    Query this sorted collection for items greater than or equal to a supplied value.

    The returned collection is not a copy but a view into the collection.

    The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

    Declaration
    IDirectedEnumerable<T> RangeFrom(T bot)
    Parameters
    Type Name Description
    T bot

    The lower bound (inclusive).

    Returns
    Type Description
    IDirectedEnumerable<T>

    The result directed collection.

    | Improve this Doc View Source

    RangeFromTo(T, T)

    Query this sorted collection for items between two supplied values.

    The returned collection is not a copy but a view into the collection.

    The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

    Declaration
    IDirectedEnumerable<T> RangeFromTo(T bot, T top)
    Parameters
    Type Name Description
    T bot

    The lower bound (inclusive).

    T top

    The upper bound (exclusive).

    Returns
    Type Description
    IDirectedEnumerable<T>

    The result directed collection.

    | Improve this Doc View Source

    RangeTo(T)

    Query this sorted collection for items less than a supplied value.

    The returned collection is not a copy but a view into the collection.

    The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

    Declaration
    IDirectedEnumerable<T> RangeTo(T top)
    Parameters
    Type Name Description
    T top

    The upper bound (exclusive).

    Returns
    Type Description
    IDirectedEnumerable<T>

    The result directed collection.

    | Improve this Doc View Source

    RemoveRangeFrom(T)

    Remove all items of this collection above or at a supplied threshold.

    Declaration
    void RemoveRangeFrom(T low)
    Parameters
    Type Name Description
    T low

    The lower threshold (inclusive).

    | Improve this Doc View Source

    RemoveRangeFromTo(T, T)

    Remove all items of this collection between two supplied thresholds.

    Declaration
    void RemoveRangeFromTo(T low, T hi)
    Parameters
    Type Name Description
    T low

    The lower threshold (inclusive).

    T hi

    The upper threshold (exclusive).

    | Improve this Doc View Source

    RemoveRangeTo(T)

    Remove all items of this collection below a supplied threshold.

    Declaration
    void RemoveRangeTo(T hi)
    Parameters
    Type Name Description
    T hi

    The upper threshold (exclusive).

    | Improve this Doc View Source

    Successor(T)

    Find the strict successor in the sorted collection of a particular value, that is, the least item in the collection greater than the supplied value.

    Declaration
    T Successor(T item)
    Parameters
    Type Name Description
    T item

    The item to find the successor for.

    Returns
    Type Description
    T

    The successor.

    Exceptions
    Type Condition
    NoSuchItemException

    if no such element exists (the supplied value is greater than or equal to the maximum of this collection.)

    | Improve this Doc View Source

    TryPredecessor(T, out T)

    Find the strict predecessor of item in the sorted collection, that is, the greatest item in the collection smaller than the item.

    Declaration
    bool TryPredecessor(T item, out T res)
    Parameters
    Type Name Description
    T item

    The item to find the predecessor for.

    T res

    The predecessor, if any; otherwise the default value for T.

    Returns
    Type Description
    System.Boolean

    True if item has a predecessor; otherwise false.

    | Improve this Doc View Source

    TrySuccessor(T, out T)

    Find the strict successor of item in the sorted collection, that is, the least item in the collection greater than the supplied value.

    Declaration
    bool TrySuccessor(T item, out T res)
    Parameters
    Type Name Description
    T item

    The item to find the successor for.

    T res

    The successor, if any; otherwise the default value for T.

    Returns
    Type Description
    System.Boolean

    True if item has a successor; otherwise false.

    | Improve this Doc View Source

    TryWeakPredecessor(T, out T)

    Find the weak predecessor of item in the sorted collection, that is, the greatest item in the collection smaller than or equal to the item.

    Declaration
    bool TryWeakPredecessor(T item, out T res)
    Parameters
    Type Name Description
    T item

    The item to find the weak predecessor for.

    T res

    The weak predecessor, if any; otherwise the default value for T.

    Returns
    Type Description
    System.Boolean

    True if item has a weak predecessor; otherwise false.

    | Improve this Doc View Source

    TryWeakSuccessor(T, out T)

    Find the weak successor of item in the sorted collection, that is, the least item in the collection greater than or equal to the supplied value.

    Declaration
    bool TryWeakSuccessor(T item, out T res)
    Parameters
    Type Name Description
    T item

    The item to find the weak successor for.

    T res

    The weak successor, if any; otherwise the default value for T.

    Returns
    Type Description
    System.Boolean

    True if item has a weak successor; otherwise false.

    | Improve this Doc View Source

    WeakPredecessor(T)

    Find the weak predecessor in the sorted collection of a particular value, that is, the largest item in the collection less than or equal to the supplied value.

    Declaration
    T WeakPredecessor(T item)
    Parameters
    Type Name Description
    T item

    The item to find the weak predecessor for.

    Returns
    Type Description
    T

    The weak predecessor.

    Exceptions
    Type Condition
    NoSuchItemException

    if no such element exists (the supplied value is less than the minimum of this collection.)

    | Improve this Doc View Source

    WeakSuccessor(T)

    Find the weak successor in the sorted collection of a particular value, that is, the least item in the collection greater than or equal to the supplied value.

    Declaration
    T WeakSuccessor(T item)
    Parameters
    Type Name Description
    T item

    The item to find the weak successor for.

    Returns
    Type Description
    T

    The weak successor.

    Exceptions
    Type Condition
    NoSuchItemException

    if no such element exists (the supplied value is greater than the maximum of this collection.)

    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)