com.opmath.util.datastruct
Class SortedTableIndex
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.Vector
|
+--com.opmath.util.datastruct.ComparableVector
|
+--com.opmath.util.datastruct.SortedTableIndex
- All Implemented Interfaces:
- Cloneable, Collection, ComparableList, List, Serializable
- public class SortedTableIndex
- extends ComparableVector
Provides the means to construct a sorted index for a ComparableTable.
The sorted index function is the familiar one for data tables: a number of columns are nominated, in
decreasing order of importance - all rows are sorted for field values in the first column, and subsequent
columns are used as 'tie-breakers'.
All field values in the given ComparableTable must implement the java.util.Comparable
interface. Since this is the only restriction on the nature of field values, it is up to the programmer
to ensure that 'sensible' comparisons are being made.
SortedTableIndex provides its own private class in order to implement an insert sort algorithm. The
algorithm is not particularly efficient, but is not disasterous either: where only one column is used for the
sort (or no equal values are found) the cost is in the order (n2)/4 comparisons and n inserts.
Where further columns are used, and equal values are found, the number of comparisons and inserts grows linearly.
SortedTableIndex implements the ComparableList interface by inheriting from
ComparableVector. Access methods for SortedTableIndex are therefore as per
ComparableList.
Note that the structures used to implement the sort are discarded by the SortedTableIndex constructor
in order to minimize memory requirements.
Copyright: (c) 2002 The Open Math Company Limited
The Terms of Distribution of this software are stipulated in the javadoc
Overview for this project.
- Since:
- J2SE 1.3
- Version:
- DataStruct v1.0 r1
- Author:
- Bruno Beloff bruno.beloff@opmath.com
- See Also:
- Serialized Form
| 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, trimToSize |
SortedTableIndex
public SortedTableIndex(ComparableTable display,
ComparableList columnKeys)
throws ComparableTableException
- Constructs a new sorted index for the given
ComparableTable.
- Parameters:
display - the ComparableTable for the sort index.columnKeys - the ComparableList identifying the sort columns.- Throws:
ComparableTableException - An exception thrown if
any column identified in columnKeys is not known to the
ComparableTable instance.- Since:
- J2SE 1.3
Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK