OSMQ
v2.0.1

osmq.util
Class KeyedOrderedList

java.lang.Object
  extended byosmq.util.KeyedOrderedList
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class KeyedOrderedList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A collection of objects accessible by position or key.

Items may be accessed by row position (zero offset) or key value.

See Also:
Serialized Form

Field Summary
static int ADDED
           
static int NONE
           
static int REMOVED
           
static int REPLACED
           
 
Constructor Summary
KeyedOrderedList()
           
 
Method Summary
 long added()
           
 void clear()
          Removes all table entries and resets counters to zero.
 java.lang.Object clone()
           
 boolean contains(java.lang.Object k)
          Identifies whether there is a KeyedData item in the set with a matching key value
 KeyedData first()
          Returns the first KeyedData item in the collection, or null if the collection is empty.
 KeyedData get(int p)
          Returns the KeyedData item at row position p;
 KeyedData get(java.lang.Object k)
          Returns the KeyedData item with the key value of k.
 java.util.Iterator getIterator()
          Returns an iterator to the KeyedOrderedList.
 int getLastChange()
           
 KeyedData getNext()
          First call returns the first KeyedData item in the collection, and subsequent calls return each of the subsequent items.
 boolean isEmpty()
           
 boolean isUseKeys()
          Returns true if keys are being used.
static KeyedOrderedList loadList(java.lang.String filename)
          Creates a KeyedOrderedList from the serialized instance saved to a file.
 void put(KeyedData r)
          Adds a KeyedData item to the list if there is no item with a matching key.
 void remove(int p)
          Removes a KeyedData item from the list.
 void save(java.lang.String filename)
          Saves a serialized instance of the KeyedOrderedList to a file.
 void setUseKeys(boolean k)
          If true, key value of object will determine whether an object is added or replaced when put() is called.
 void showContents()
           
 void showContents(Log lg)
           
 int size()
           
 long updated()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
See Also:
Constant Field Values

ADDED

public static final int ADDED
See Also:
Constant Field Values

REPLACED

public static final int REPLACED
See Also:
Constant Field Values

REMOVED

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

KeyedOrderedList

public KeyedOrderedList()
Method Detail

size

public final int size()

isEmpty

public final boolean isEmpty()

added

public final long added()

updated

public final long updated()

put

public void put(KeyedData r)
Adds a KeyedData item to the list if there is no item with a matching key. Otherwise, replaces the matching item.

Parameters:
r - KeyedData item to add/replace in the list

get

public final KeyedData get(java.lang.Object k)
Returns the KeyedData item with the key value of k. If no matching item is found, returns null.


get

public final KeyedData get(int p)
Returns the KeyedData item at row position p;


contains

public final boolean contains(java.lang.Object k)
Identifies whether there is a KeyedData item in the set with a matching key value

Returns:
true if the set contains a KeyedData item with a key value of k

setUseKeys

public final void setUseKeys(boolean k)
If true, key value of object will determine whether an object is added or replaced when put() is called. If false, keys will be ignored when put() is called, permitting rows with duplicate keys. (Default is true -- replacement if a duplicate key)


isUseKeys

public final boolean isUseKeys()
Returns true if keys are being used. Key values determine whether an object is added or replaced when a put(Object) method is called. If keys are not used, all elements are appended to the list.


remove

public final void remove(int p)
Removes a KeyedData item from the list.

Parameters:
p - position in the list of element to be removed.

getLastChange

public final int getLastChange()

getNext

public final KeyedData getNext()
First call returns the first KeyedData item in the collection, and subsequent calls return each of the subsequent items. Returns the value null if the collection is empty, or if the prior call returned the last item. (After a null is returned, subsequent calls will initiate iteration beginning with the first KeyedData item.)


first

public final KeyedData first()
Returns the first KeyedData item in the collection, or null if the collection is empty.


loadList

public static KeyedOrderedList loadList(java.lang.String filename)
Creates a KeyedOrderedList from the serialized instance saved to a file.

Parameters:
filename - name of the file containing the serialized KeyedOrderedList instance.

save

public void save(java.lang.String filename)
Saves a serialized instance of the KeyedOrderedList to a file.

Parameters:
filename - name to assign the file.

showContents

public void showContents(Log lg)

showContents

public void showContents()

clear

public final void clear()
Removes all table entries and resets counters to zero.


getIterator

public java.util.Iterator getIterator()
Returns an iterator to the KeyedOrderedList.


clone

public java.lang.Object clone()

(c) 2000 - 2003 MQue Systems
All Rights Reserved