ostore.util
Class QSWindow

java.lang.Object
  |
  +--ostore.util.QSWindow
All Implemented Interfaces:
QuickSerializable

public class QSWindow
extends Object
implements QuickSerializable

The QSWindow object is a data structure similiar to a queue. It can store up to a fixed amount of QuickSerializable objects, and once it contains that many objects, it begins overwriting the least recent object added to it. In this way, it represents a kind of window of objects in time that it can hold.

There is probably a lot of functionality that can be added to this object to make it more useful. Please feel free to add to it as necessary.

Version:
$Id: QSWindow.java,v 1.11 2002/07/20 19:38:03 srhea Exp $
Author:
Jeremy Stribling

Field Summary
static int DEFAULT_SIZE
           
 
Constructor Summary
QSWindow()
          Construct a QSWindow with a default maximum capacity.
QSWindow(InputBuffer buffer)
          Constructs a QSWindow from its QuickSerializable form.
QSWindow(int windowSize)
          Construct a QSWindow object with the given maximum capacity.
 
Method Summary
 void add(QuickSerializable datum)
          Add this object to the window.
 void clear()
          Forget about all elements currently in the window.
 void clear(int num)
          Forget about a certain number of the least-recently added data.
 void serialize(OutputBuffer buffer)
          Specified by the QuickSerializable interface.
 QuickSerializable[] toArray()
          Convert the elements in this window to an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

public static final int DEFAULT_SIZE
See Also:
Constant Field Values
Constructor Detail

QSWindow

public QSWindow(int windowSize)
Construct a QSWindow object with the given maximum capacity.

Parameters:
windowSize - the maximum capacity of this window

QSWindow

public QSWindow()
Construct a QSWindow with a default maximum capacity. Currently this default is 1000.


QSWindow

public QSWindow(InputBuffer buffer)
         throws QSException
Constructs a QSWindow from its QuickSerializable form.

Method Detail

serialize

public void serialize(OutputBuffer buffer)
Specified by the QuickSerializable interface.

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to

add

public void add(QuickSerializable datum)
Add this object to the window. If the window is at maximum capacity, overwrite the least recently added object.

Parameters:
datum - the object to add

clear

public void clear(int num)
Forget about a certain number of the least-recently added data.

Parameters:
num - the number of elements to forget

clear

public void clear()
Forget about all elements currently in the window.


toArray

public QuickSerializable[] toArray()
Convert the elements in this window to an array. No order of the elements is guaranteed within this array.