org.apache.avalon.excalibur.collections
クラス BinaryHeap

java.lang.Object
  |
  +--org.apache.avalon.excalibur.collections.BinaryHeap
すべての実装インタフェース:
PriorityQueue

public final class BinaryHeap
extends java.lang.Object
implements PriorityQueue

BinaryHeap implementation of priority queue. The heap is either a minimum or maximum heap as determined by parameters passed to constructor.

導入されたバージョン:
4.0
バージョン:
CVS $Revision: 1.7 $ $Date: 2001/12/11 09:53:26 $
作成者:
Peter Donald, Ram Chidambaram, Chad Stansbury

フィールドの概要
static java.util.Comparator MAX_COMPARATOR
          Comparator used to instantiate a max heap - assumes contents implement the Comparable interface.
static java.util.Comparator MIN_COMPARATOR
          Comparator used to instantiate a min heap - assumes contents implement the Comparable interface.
 
コンストラクタの概要
BinaryHeap()
          Instantiates a new min binary heap with the default initial capacity.
BinaryHeap(boolean isMinHeap)
          Create a binary heap of Comparables.
BinaryHeap(java.util.Comparator comparator)
          Instantiates a new binary heap with the default initial capacity and ordered using the given Comparator.
BinaryHeap(int capacity)
          Instantiates a new min binary heap with the given initial capacity.
BinaryHeap(int capacity, boolean isMinHeap)
          Create a binary heap of Comparables.
BinaryHeap(int capacity, java.util.Comparator comparator)
          Instantiates a new binary heap with the given initial capacity and ordered using the given Comparator.
 
メソッドの概要
 void clear()
          Clear all elements from queue.
 void insert(java.lang.Object element)
          Insert an element into queue.
 boolean isEmpty()
          Test if queue is empty.
 boolean isFull()
          Test if queue is full.
 java.lang.Object peek()
          Return element on top of heap but don't remove it.
 java.lang.Object pop()
          Return element on top of heap and remove it.
 int size()
          Returns the number of elements currently on the heap.
 java.lang.String toString()
          Create a string representing heap and all elements in heap.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

MIN_COMPARATOR

public static final java.util.Comparator MIN_COMPARATOR
Comparator used to instantiate a min heap - assumes contents implement the Comparable interface.

MAX_COMPARATOR

public static final java.util.Comparator MAX_COMPARATOR
Comparator used to instantiate a max heap - assumes contents implement the Comparable interface.
コンストラクタの詳細

BinaryHeap

public BinaryHeap()
Instantiates a new min binary heap with the default initial capacity.

BinaryHeap

public BinaryHeap(int capacity)
Instantiates a new min binary heap with the given initial capacity.
パラメータ:
capacity - the size of the heap

BinaryHeap

public BinaryHeap(java.util.Comparator comparator)
Instantiates a new binary heap with the default initial capacity and ordered using the given Comparator.
パラメータ:
comparator - to order the contents of the heap

BinaryHeap

public BinaryHeap(int capacity,
                  java.util.Comparator comparator)
Instantiates a new binary heap with the given initial capacity and ordered using the given Comparator.
パラメータ:
capacity - the size of the heap
comparator - to order the contents of the heap

BinaryHeap

public BinaryHeap(boolean isMinHeap)
Create a binary heap of Comparables. Takes a parameter to specify whether it is a minimum or maximum heap.
パラメータ:
isMinHeap - true to make it a minimum heap, false to make it a max heap

BinaryHeap

public BinaryHeap(int capacity,
                  boolean isMinHeap)
Create a binary heap of Comparables. Takes a parameter to specify whether it is a minimum or maximum heap and another parameter to specify the size of the heap.
パラメータ:
capacity - the size of the heap
isMinHeap - true to make it a minimum heap, false to make it a max heap
メソッドの詳細

clear

public void clear()
Clear all elements from queue.
定義:
インタフェース PriorityQueue 内の clear

isEmpty

public boolean isEmpty()
Test if queue is empty.
定義:
インタフェース PriorityQueue 内の isEmpty
戻り値:
true if queue is empty else false.

isFull

public boolean isFull()
Test if queue is full.
戻り値:
true if queue is full else false.

size

public int size()
Returns the number of elements currently on the heap.
戻り値:
the size of the heap.

insert

public void insert(java.lang.Object element)
Insert an element into queue.
定義:
インタフェース PriorityQueue 内の insert
パラメータ:
element - the element to be inserted

peek

public java.lang.Object peek()
                      throws java.util.NoSuchElementException
Return element on top of heap but don't remove it.
定義:
インタフェース PriorityQueue 内の peek
戻り値:
the element at top of heap
例外:
java.util.NoSuchElementException - if isEmpty() == true

pop

public java.lang.Object pop()
                     throws java.util.NoSuchElementException
Return element on top of heap and remove it.
定義:
インタフェース PriorityQueue 内の pop
戻り値:
the element at top of heap
例外:
java.util.NoSuchElementException - if isEmpty() == true

toString

public java.lang.String toString()
Create a string representing heap and all elements in heap.
オーバーライド:
クラス java.lang.Object 内の toString
戻り値:
the string representing heap


"Copyright ? 2001 Apache Jakarta Project. All Rights Reserved."