Module org.hsqldb

Class HsqlArrayHeap<E>

java.lang.Object
org.hsqldb.lib.HsqlArrayHeap<E>
All Implemented Interfaces:
HsqlHeap<E>

public class HsqlArrayHeap<E> extends Object implements HsqlHeap<E>
An HsqlHeap implementation backed by an array of objects and an ObjectComparator. This implementation is non-blocking, dynamically resizing and thread-safe.
Since:
1.7.2
Author:
Campbell Burnet (campbell-burnet@users dot sourceforge.net)
  • Constructor Summary

    Constructors
    Constructor
    Description
    HsqlArrayHeap(int capacity, Comparator<E> comparator)
    Creates a new HsqlArrayHeap with the given initial capacity, using the specified ObjectComparator to maintain the heap invariant.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(E o)
    Adds the specified element to this Heap.
    void
    Removes all of the elements from this Heap.
    boolean
    Retrieves whether this Heap is empty.
    boolean
    Retrieves whether this Heap is full.
    Retrieves the least element from this Heap, without removing it.
    Retrieves the least element from this Heap, removing it in the process.
    int
    Retrieves the number of elements currently in this Heap.
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • HsqlArrayHeap

      public HsqlArrayHeap(int capacity, Comparator<E> comparator) throws IllegalArgumentException
      Creates a new HsqlArrayHeap with the given initial capacity, using the specified ObjectComparator to maintain the heap invariant.
      Parameters:
      capacity - int
      comparator - Comparator
      Throws:
      IllegalArgumentException - if capacity less or equal to zero or comparator is null
  • Method Details

    • clear

      public void clear()
      Description copied from interface: HsqlHeap
      Removes all of the elements from this Heap.
      Specified by:
      clear in interface HsqlHeap<E>
    • add

      public boolean add(E o)
      Description copied from interface: HsqlHeap
      Adds the specified element to this Heap.
      Specified by:
      add in interface HsqlHeap<E>
      Parameters:
      o - The element to add
      Returns:
      boolean
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: HsqlHeap
      Retrieves whether this Heap is empty.
      Specified by:
      isEmpty in interface HsqlHeap<E>
      Returns:
      boolean
    • isFull

      public boolean isFull()
      Description copied from interface: HsqlHeap
      Retrieves whether this Heap is full.
      Specified by:
      isFull in interface HsqlHeap<E>
      Returns:
      boolean
    • peek

      public E peek()
      Description copied from interface: HsqlHeap
      Retrieves the least element from this Heap, without removing it.
      Specified by:
      peek in interface HsqlHeap<E>
      Returns:
      the least element from this Heap
    • remove

      public E remove()
      Description copied from interface: HsqlHeap
      Retrieves the least element from this Heap, removing it in the process.
      Specified by:
      remove in interface HsqlHeap<E>
      Returns:
      the least element from this Heap
    • size

      public int size()
      Description copied from interface: HsqlHeap
      Retrieves the number of elements currently in this Heap.
      Specified by:
      size in interface HsqlHeap<E>
      Returns:
      the number of elements currently in this Heap
    • toString

      public String toString()
      Overrides:
      toString in class Object