org.hsqldb.lib
Class HsqlArrayHeap

java.lang.Object
  extended byorg.hsqldb.lib.HsqlArrayHeap
All Implemented Interfaces:
HsqlHeap
Direct Known Subclasses:
HsqlTimer.TaskQueue

public class HsqlArrayHeap
extends Object
implements HsqlHeap

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
Version:
1.7.2
Author:
boucherb@users.sourceforge.net

Field Summary
protected  int count
           
protected  Object[] heap
           
protected  ObjectComparator oc
           
 
Constructor Summary
HsqlArrayHeap(int capacity, ObjectComparator comparator)
          Creates a new HsqlArrayHeap with the given initial capacity, using the specified ObjectComparator to maintain the heap invariant.
 
Method Summary
 void add(Object o)
          Adds the specified element to this Heap.
 void clear()
          Removes all of the elements from this Heap.
 boolean isEmpty()
          Retrieves whether this Heap is empty.
 boolean isFull()
          Retrieves whether this Heap is full.
 Object peek()
          Retrieves the least element from this Heap, without removing it.
 Object remove()
          Retrieves the least element from this Heap, removing it in the process.
 int size()
          Retrieves the number of elements currently in this Heap.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

oc

protected ObjectComparator oc

count

protected int count

heap

protected Object[] heap
Constructor Detail

HsqlArrayHeap

public HsqlArrayHeap(int capacity,
                     ObjectComparator comparator)
              throws IllegalArgumentException
Creates a new HsqlArrayHeap with the given initial capacity, using the specified ObjectComparator to maintain the heap invariant.

Throws:
IllegalArgumentException - if capacity less or equal to zero or comparator is null
Method Detail

clear

public void clear()
Description copied from interface: HsqlHeap
Removes all of the elements from this Heap.

Specified by:
clear in interface HsqlHeap

add

public void add(Object o)
         throws IllegalArgumentException,
                RuntimeException
Description copied from interface: HsqlHeap
Adds the specified element to this Heap.

Specified by:
add in interface HsqlHeap
Parameters:
o - The element to add
Throws:
IllegalArgumentException - if the implementation does not accept elements of the supplied type (optional) throws HsqlUnsupportedOperationException if the implementation dictates that this Heap is not currently accepting additions or that this Heap is currently full (optional)
RuntimeException

isEmpty

public boolean isEmpty()
Description copied from interface: HsqlHeap
Retrieves whether this Heap is empty.

Specified by:
isEmpty in interface HsqlHeap

isFull

public boolean isFull()
Description copied from interface: HsqlHeap
Retrieves whether this Heap is full.

Specified by:
isFull in interface HsqlHeap

peek

public Object peek()
Description copied from interface: HsqlHeap
Retrieves the least element from this Heap, without removing it.

Specified by:
peek in interface HsqlHeap
Returns:
the least element from this Heap

remove

public Object remove()
Description copied from interface: HsqlHeap
Retrieves the least element from this Heap, removing it in the process.

Specified by:
remove in interface HsqlHeap
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
Returns:
the number of elements currently in this Heap

toString

public String toString()


Copyright © 2001 - 2004 HSQL Development Group. All Rights Reserved.