Class BlockingFloatHeap

java.lang.Object
org.apache.lucene.util.hnsw.BlockingFloatHeap

public final class BlockingFloatHeap extends Object
A blocking bounded min heap that stores floats. The top element is the lowest value of the heap.

A primitive priority queue that maintains a partial ordering of its elements such that the least element can always be found in constant time. Implementation is based on LongHeap

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockingFloatHeap(int maxSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    offer(float value)
    Inserts a value into this heap.
    float
    offer(float[] values, int len)
    Inserts array of values into this heap.
    float
    Retrieves, but does not remove, the head of this heap.
    float
    Removes and returns the head of the heap
    int
    Returns the number of elements in this heap.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BlockingFloatHeap

      public BlockingFloatHeap(int maxSize)
  • Method Details

    • offer

      public float offer(float value)
      Inserts a value into this heap.

      If the number of values would exceed the heap's maxSize, the least value is discarded

      Parameters:
      value - the value to add
      Returns:
      the new 'top' element in the queue.
    • offer

      public float offer(float[] values, int len)
      Inserts array of values into this heap.

      Values must be sorted in ascending order.

      Parameters:
      values - a set of values to insert, must be sorted in ascending order
      len - number of values from the values array to insert
      Returns:
      the new 'top' element in the queue.
    • poll

      public float poll()
      Removes and returns the head of the heap
      Returns:
      the head of the heap, the smallest value
      Throws:
      IllegalStateException - if the heap is empty
    • peek

      public float peek()
      Retrieves, but does not remove, the head of this heap.
      Returns:
      the head of the heap, the smallest value
    • size

      public int size()
      Returns the number of elements in this heap.
      Returns:
      the number of elements in this heap