org.hsqldb.lib
Interface HsqlHeap
-
- All Known Implementing Classes:
- HsqlArrayHeap
public interface HsqlHeapProvides the base HSQLDB 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 stragegy.
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).
- Since:
- 1.7.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidadd(java.lang.Object o)Adds the specified element to this Heap.voidclear()Removes all of the elements from this Heap.booleanisEmpty()Retrieves whether this Heap is empty.booleanisFull()Retrieves whether this Heap is full.java.lang.Objectpeek()Retrieves the least element from this Heap, without removing it.java.lang.Objectremove()Retrieves the least element from this Heap, removing it in the process.intsize()Retrieves the number of elements currently in this Heap.
-
-
-
Method Detail
-
clear
void clear()
Removes all of the elements from this Heap.
-
isEmpty
boolean isEmpty()
Retrieves whether this Heap is empty.
-
isFull
boolean isFull()
Retrieves whether this Heap is full.
-
add
void add(java.lang.Object o) throws java.lang.IllegalArgumentException, java.lang.RuntimeExceptionAdds the specified element to this Heap.- Parameters:
o- The element to add- Throws:
java.lang.IllegalArgumentException- if the implementation does not accept elements of the supplied type (optional) throws RuntimeException if the implementation dictates that this Heap is not currently accepting additions or that this Heap is currently full (optional)java.lang.RuntimeException
-
peek
java.lang.Object peek()
Retrieves the least element from this Heap, without removing it.- Returns:
- the least element from this Heap
-
remove
java.lang.Object remove()
Retrieves the least element from this Heap, removing it in the process.- Returns:
- the least element from this Heap
-
size
int size()
Retrieves the number of elements currently in this Heap.- Returns:
- the number of elements currently in this Heap
-
-
DataMelt 3.0 © DataMelt by jWork.ORG