Show / Hide Table of Contents

    Class PriorityQueue<T>

    A PriorityQueue<T> holds elements on a priority heap, which orders the elements according to their natural order or according to the comparator specified at construction time. If the queue uses natural ordering, only elements that are comparable are permitted to be inserted into the queue.

    The least element of the specified ordering is stored at the head of the queue and the greatest element is stored at the tail of the queue.

    A PriorityQueue<T> is not synchronized.

    Inheritance
    System.Object
    PriorityQueue<T>
    Namespace: Lucene.Net.Support
    Assembly: Lucene.Net.dll
    Syntax
    public class PriorityQueue<T> : ICollection<T> where T : class
    Type Parameters
    Name Description
    T

    Type of elements

    Constructors

    | Improve this Doc View Source

    PriorityQueue()

    Constructs a priority queue with an initial capacity of 11 and natural ordering.

    Declaration
    public PriorityQueue()
    | Improve this Doc View Source

    PriorityQueue(ICollection<T>)

    Creates a PriorityQueue<T> containing the elements in the specified collection. If the specified collection is an instance of a , TreeSet<T>, or is another PriorityQueue<T>, this priority queue will be ordered according to the same ordering. Otherwise, this priority queue will be ordered according to the natural ordering of its elements.

    Declaration
    public PriorityQueue(ICollection<T> collection)
    Parameters
    Type Name Description
    ICollection<T> collection

    collection to be inserted into priority queue

    | Improve this Doc View Source

    PriorityQueue(IComparer<T>)

    Constructs a priority queue with the specified capacity and comparer.

    Declaration
    public PriorityQueue(IComparer<T> comparer)
    Parameters
    Type Name Description
    IComparer<T> comparer

    The that will be used to order this priority queue. If null, the natural ordering of the elements will be used.

    | Improve this Doc View Source

    PriorityQueue(PriorityQueue<T>)

    Creates a PriorityQueue<T> containing the elements in the specified priority queue. This priority queue will be ordered according to the same ordering as the given priority queue.

    Declaration
    public PriorityQueue(PriorityQueue<T> collection)
    Parameters
    Type Name Description
    PriorityQueue<T> collection

    the priority queue whose elements are to be placed into this priority queue

    | Improve this Doc View Source

    PriorityQueue(TreeSet<T>)

    Creates a PriorityQueue<T> containing the elements in the specified TreeSet<T>. This priority queue will be ordered according to the same ordering as the given TreeSet<T>.

    The constructed priority queue has the initial capacity of 110% of the size of the sorted set. The priority queue will have the same comparator as the sorted set.

    Declaration
    public PriorityQueue(TreeSet<T> collection)
    Parameters
    Type Name Description
    TreeSet<T> collection

    the sorted set whose elements are to be placed into this priority queue

    | Improve this Doc View Source

    PriorityQueue(SortedSet<T>)

    Creates a PriorityQueue<T> containing the elements in the specified . This priority queue will be ordered according to the same ordering as the given .

    The constructed priority queue has the initial capacity of 110% of the size of the sorted set. The priority queue will have the same comparator as the sorted set.

    Declaration
    public PriorityQueue(SortedSet<T> collection)
    Parameters
    Type Name Description
    SortedSet<T> collection

    the sorted set whose elements are to be placed into this priority queue

    | Improve this Doc View Source

    PriorityQueue(Int32)

    Constructs a priority queue with the specified capacity and natural ordering.

    Declaration
    public PriorityQueue(int initialCapacity)
    Parameters
    Type Name Description
    System.Int32 initialCapacity

    initial capacity

    | Improve this Doc View Source

    PriorityQueue(Int32, IComparer<T>)

    Creates a PriorityQueue<T> with the specified initial capacity that orders its elements according to the specified comparer.

    Declaration
    public PriorityQueue(int initialCapacity, IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Int32 initialCapacity

    the initial capacity for this priority queue

    IComparer<T> comparer

    The that will be used to order this priority queue. If null, the natural ordering of the elements will be used.

    Properties

    | Improve this Doc View Source

    Comparer

    Gets the used to order the elements in this queue, or Lucene.Net.Util.ArrayUtil.NaturalComparer`1 if this queue is sorted according to the natural ordering of its elements.

    Declaration
    public virtual IComparer<T> Comparer { get; }
    Property Value
    Type Description
    IComparer<T>
    | Improve this Doc View Source

    Count

    Gets the size of the priority queue. If the size of the queue is greater than the , then it returns .

    Declaration
    public virtual int Count { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    IsReadOnly

    Gets a value indicating whether the collection is read-only.

    Declaration
    public virtual bool IsReadOnly { get; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    For priority queue this property returns false.

    Methods

    | Improve this Doc View Source

    Add(T)

    Adds the specified object to the priority queue.

    Declaration
    public virtual void Add(T item)
    Parameters
    Type Name Description
    T item

    the object to be added.

    | Improve this Doc View Source

    AddAll(ICollection<T>)

    Declaration
    public virtual bool AddAll(ICollection<T> collection)
    Parameters
    Type Name Description
    ICollection<T> collection
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Clear()

    Removes all of the elements from this priority queue.

    Declaration
    public virtual void Clear()
    | Improve this Doc View Source

    Contains(T)

    Returns true if this queue contains the specified element. More formally, returns true if and only if this queue contains at least one element item such that o.Equals(item).

    Declaration
    public virtual bool Contains(T item)
    Parameters
    Type Name Description
    T item

    The object to locate in the priority queue

    Returns
    Type Description
    System.Boolean

    true if item is found in the priority queue; otherwise, false.

    | Improve this Doc View Source

    CopyTo(T[], Int32)

    Copies the elements of the priority queue to an Array, starting at a particular Array index.

    Declaration
    public virtual void CopyTo(T[] array, int arrayIndex)
    Parameters
    Type Name Description
    T[] array

    The one-dimensional Array that is the destination of the elements copied from the priority queue. The Array must have zero-based indexing.

    System.Int32 arrayIndex

    The zero-based index in array at which copying begins.

    Remarks

    It is not guaranteed that items will be copied in the sorted order.

    | Improve this Doc View Source

    Element()

    Retrieves, but does not remove, the head of this queue. This method differs from Peek() only in that it throws an exception if this queue is empty.

    This implementation returns the result of Peek() unless the queue is empty.

    Declaration
    public virtual T Element()
    Returns
    Type Description
    T

    the head of this queue

    | Improve this Doc View Source

    GetEnumerator()

    Gets the enumerator of the priority queue, which will not return elements in any specified ordering.

    Declaration
    public virtual IEnumerator<T> GetEnumerator()
    Returns
    Type Description
    IEnumerator<T>

    The enumerator of the priority queue.

    Remarks

    Returned enumerator does not iterate elements in sorted order.

    | Improve this Doc View Source

    Offer(T)

    Inserts the specified element into this priority queue.

    Declaration
    public virtual bool Offer(T item)
    Parameters
    Type Name Description
    T item

    the element to add to the priority queue.

    Returns
    Type Description
    System.Boolean

    always true

    | Improve this Doc View Source

    Peek()

    Gets but does not remove the head of the queue.

    Declaration
    public virtual T Peek()
    Returns
    Type Description
    T

    the head of the queue or null if the queue is empty.

    | Improve this Doc View Source

    Poll()

    Gets and removes the head of the queue.

    Declaration
    public virtual T Poll()
    Returns
    Type Description
    T

    the head of the queue or null if the queue is empty.

    | Improve this Doc View Source

    Remove()

    Retrieves and removes the head of this queue. This method differs from Poll() only in that it throws an exception if this queue is empty.

    This implementation returns the result of Poll() unless the queue is empty.

    Declaration
    public virtual T Remove()
    Returns
    Type Description
    T

    the head of this queue

    | Improve this Doc View Source

    Remove(T)

    Removes the specified object from the priority queue.

    Declaration
    public virtual bool Remove(T item)
    Parameters
    Type Name Description
    T item

    the object to be removed.

    Returns
    Type Description
    System.Boolean

    true if the object was in the priority queue, false if the object

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