Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class PriorityComparer<T>

    An adapter comparer for use with ValuePriorityQueue<T>.

    This comparer makes it easy to convert PriorityQueue<T>-derived subclasses into comparers that can be used with ValuePriorityQueue<T>.

    NOTE: This adapter converts the 2-state LessThan(T, T) method to the 3-state Compare(T, T) by always assuming if LessThan(T, T) returns false that the left node is greater than the right node. This means nodes will never compare equal, even if they actually are. Therefore, it may not work correctly for most applications of IComparer<T>, but will work correctly with ValuePriorityQueue<T>.
    Inheritance
    object
    PriorityComparer<T>
    Implements
    IComparer<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.dll
    Syntax
    public abstract class PriorityComparer<T> : IComparer<T>
    Type Parameters
    Name Description
    T

    The type of item to compare. This may be either a value type or a reference type.

    Methods

    LessThan(T, T)

    Determines the ordering of objects in this priority queue. Subclasses must define this one method.

    Declaration
    protected abstract bool LessThan(T a, T b)
    Parameters
    Type Name Description
    T a

    The left value to compare.

    T b

    The right value to compare.

    Returns
    Type Description
    bool

    true if parameter a is less than parameter b; otherwise false.

    Implements

    IComparer<T>
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.