Top Description Methods
org.hsqldb.lib

public Interface HsqlHeap<E>

Known Direct Implementers
org.hsqldb.lib.HsqlArrayHeap

Provides the HyperSQL interface for Heap ADT implementations.

In this context, a Heap is simply a collection-like ADT that allows addition of elements and provides a way to remove the least element, given some implementation-dependent strategy for imposing an order over its elements.

Typically, an HsqlHeap will be implemented as a tree-like structure that recursively guarantees a Heap Invariant, such that all nodes below the root are greater than the root, given some comparison strategy.

This in turn provides the basis for an efficient implementation of ADTs such PriorityQueue, since Heap operations using the typical implementation are, in theory, guaranteed to be O(log n).

This interface represents a pure queue with the same basic queue methods as java.util.Queue but without all the extra methods.

Author
Campbell Burnet (campbell-burnet@users dot sourceforge.net)
Since
1.7.2
Version
2.6.0

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

boolean
add
(E
The element to add
o
)

Adds the specified element to this Heap.

public void
clear()

Removes all elements from this Heap.

public boolean

Returns:

boolean
isEmpty
()

Retrieves whether this Heap is empty.

public boolean

Returns:

boolean
isFull
()

Retrieves whether this Heap is full.

public E

Returns:

the least element from this Heap
peek
()

Retrieves the least element from this Heap, without removing it.

public E

Returns:

the least element from this Heap
remove
()

Retrieves the least element from this Heap, removing it in the process.

public int

Returns:

the number of elements currently in this Heap
size
()

Retrieves the number of elements currently in this Heap.

Method Detail

addback to summary
public boolean add(E o)

Adds the specified element to this Heap.

Parameters
o:E

The element to add

Returns:boolean

boolean

Exceptions
IllegalArgumentException:
if the implementation does not accept elements of the supplied type (optional)
RuntimeException:
if the implementation dictates that this Heap is not currently accepting additions or that this Heap is currently full (optional)
clearback to summary
public void clear()

Removes all elements from this Heap.

isEmptyback to summary
public boolean isEmpty()

Retrieves whether this Heap is empty.

Returns:boolean

boolean

isFullback to summary
public boolean isFull()

Retrieves whether this Heap is full.

Returns:boolean

boolean

peekback to summary
public E peek()

Retrieves the least element from this Heap, without removing it.

Returns:E

the least element from this Heap

removeback to summary
public E remove()

Retrieves the least element from this Heap, removing it in the process.

Returns:E

the least element from this Heap

sizeback to summary
public int size()

Retrieves the number of elements currently in this Heap.

Returns:int

the number of elements currently in this Heap