org.egothor.util
Class Queue<T>

java.lang.Object
  extended by org.egothor.util.QueueAbstract<T>
      extended by org.egothor.util.Queue<T>

public abstract class Queue<T>
extends QueueAbstract<T>

The Queue class should be extended by any class wishing to implement a priority queue (heap). The Queue object is used to aid in the merger of indices constructed for any number of document collections.

Author:
Leo Galambos

Field Summary
 T[] array
          Used by the Queue to store objects.
 
Fields inherited from class org.egothor.util.QueueAbstract
factor
 
Constructor Summary
Queue(int factor, int max)
          Constructor for the Queue object.
Queue(int factor, int init_size, int delta)
          Constructor for the Queue object
 
Method Summary
 void append(T obj)
          Add the given object to the end of the queue.
 int capacity()
          Return the capacity of this Queue as defined in the constructor.
 void clear()
          Description of the Method
 void cutOffLast()
          Shrink the Queue by 1 (the last) position.
 void expand()
          Description of the Method
 T item(int index)
          Return the object at the given position in the Queue.
 void itemto(int index, T obj)
          Insert the given object in the Queue at the specified position.
 int lowestSonOf(int father)
          Find an item with the lowest value amongst sons of a father.
 int size()
          Return the number of elements in the queue.
 
Methods inherited from class org.egothor.util.QueueAbstract
down, down, lessThan, peek, pop, push, replace, up
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

public transient T[] array
Used by the Queue to store objects.

Constructor Detail

Queue

public Queue(int factor,
             int max)
Constructor for the Queue object.

Parameters:
max - the maximum size desired for the Queue

Queue

public Queue(int factor,
             int init_size,
             int delta)
Constructor for the Queue object

Parameters:
init_size - Description of the Parameter
delta - Description of the Parameter
Method Detail

clear

public final void clear()
Description of the Method


expand

public final void expand()
Description of the Method

Overrides:
expand in class QueueAbstract<T>

size

public final int size()
Return the number of elements in the queue.

Specified by:
size in class QueueAbstract<T>
Returns:
the number of elements in the queue

item

public final T item(int index)
Return the object at the given position in the Queue.

Specified by:
item in class QueueAbstract<T>
Parameters:
index - the position of the desired object
Returns:
the object at the given position in the Queue

capacity

public final int capacity()
Return the capacity of this Queue as defined in the constructor.

Specified by:
capacity in class QueueAbstract<T>
Returns:
the capacity

itemto

public final void itemto(int index,
                         T obj)
Insert the given object in the Queue at the specified position.

Specified by:
itemto in class QueueAbstract<T>
Parameters:
index - the position at which to insert
obj - the object to insert

lowestSonOf

public final int lowestSonOf(int father)
Description copied from class: QueueAbstract
Find an item with the lowest value amongst sons of a father.

Overrides:
lowestSonOf in class QueueAbstract<T>
Returns:
the index of the lowest value

cutOffLast

public final void cutOffLast()
Shrink the Queue by 1 (the last) position.

Specified by:
cutOffLast in class QueueAbstract<T>

append

public final void append(T obj)
Add the given object to the end of the queue.

Specified by:
append in class QueueAbstract<T>
Parameters:
obj - the object to append