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.1 2001/12/04 19:45:13 strib Exp $
Author:
Jeremy Stribling

Field Summary
static int DEFAULT_SIZE
           
 
Constructor Summary
QSWindow()
          Construct a QSWindow with a default maximum capacity.
QSWindow(byte[] data, int[] offset)
          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 to_bytes(byte[] data, int[] offset)
          Specified by the QuickSerializable interface.
 QuickSerializable[] toArray()
          Convert the elements in this window to an array.
 int type_code()
          Specified by the QuickSerializable interface.
 
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
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(byte[] data,
                int[] offset)
         throws QSException
Constructs a QSWindow from its QuickSerializable form.
Method Detail

to_bytes

public void to_bytes(byte[] data,
                     int[] offset)
Specified by the QuickSerializable interface.
Specified by:
to_bytes in interface QuickSerializable
Following copied from interface: ostore.util.QuickSerializable
Parameters:
data - The byte array to store into, or null.
offset - A single element array whose first element is the index in data to begin writing at on function entry, and which on function exit has been incremented by the number of bytes written.

type_code

public int type_code()
Specified by the QuickSerializable interface.
Specified by:
type_code in interface QuickSerializable
Following copied from interface: ostore.util.QuickSerializable
Returns:
an integer unique to this class

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.