org.nees.util.cache
Class MultisortVector

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.Vector
              extended byorg.nees.util.cache.MultisortVector
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class MultisortVector
extends java.util.Vector

This is an extension of a Vector that permits sorting its elements on multiple keys. The elements should all implement the Multisortable interface.

Life cycle

This can be used wherever a list needs to be multiply-sorted. Note that this is more general than the Comparable interface that is supplied by the Java language.

Usage

Use the add(Multisortable) and msAt(int) methods for adding and getting elements. When you need to sort this, invoke the sort(int) with the appropriate key from your implementation of the Multisortable interface.
One note is that if you want to have elements sorted multiply, e.g. by a date and by a string, you would issue sorts on the less important key first. So assuming you have one of thes called msv with keys NAME, DATE in your implementation,
msv.sort(NAME);
msv.sort(DATE); would sort the elements by date then name.
Finally, elements that are incomparable are returned in random order compared to the rest of the list. Creation timestamp: Feb 18, 2003 11:23:21 AM

Author:
jeff
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
MultisortVector()
          Constructor for MultisortVector.
MultisortVector(java.util.Collection arg0)
          Constructor for MultisortVector.
MultisortVector(int arg0)
          Constructor for MultisortVector.
MultisortVector(int arg0, int arg1)
          Constructor for MultisortVector.
 
Method Summary
 void add(Multisortable ms)
           
 Multisortable msAt(int index)
           
 void sort(int key)
           
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

MultisortVector

public MultisortVector(int arg0,
                       int arg1)
Constructor for MultisortVector.

Parameters:
arg0 -
arg1 -

MultisortVector

public MultisortVector(int arg0)
Constructor for MultisortVector.

Parameters:
arg0 -

MultisortVector

public MultisortVector()
Constructor for MultisortVector.


MultisortVector

public MultisortVector(java.util.Collection arg0)
Constructor for MultisortVector.

Parameters:
arg0 -
Method Detail

add

public void add(Multisortable ms)

msAt

public Multisortable msAt(int index)

sort

public void sort(int key)