net.rim.device.api.util
Class SimpleSortingVector

java.lang.Object
  |
  +--java.util.Vector
        |
        +--net.rim.device.api.util.SimpleSortingVector

public class SimpleSortingVector
extends Vector

Simple sorting vector of objects.


Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Constructor Summary
SimpleSortingVector()
          Constructs a new SimpleSortingVector instance.
 
Method Summary
 void add(Object obj)
          Deprecated. Use addElement(java.lang.Object) instead.
 void addElement(Object obj)
          Adds provided object to this vector.
 int find(Object key)
          Find an object in the vector based on a given key.
 Object getAt(int index)
          Deprecated. Use Vector.elementAt(int) instead.
 Vector getVector()
          Deprecated. SimpleSortingVector is now an instance of Vector
 void remove(int index)
          Deprecated. Use Vector.removeElementAt(int) instead.
 void removeAll()
          Deprecated. Use Vector.removeAllElements() instead.
 void reSort()
          Sorts this vector.
 boolean setSort(boolean toSort)
          Specifies whether this vector should sort dynamically.
 void setSortComparator(Comparator newComparator)
          Sets a new comparator for use with this sorting vector.
 
Methods inherited from class java.util.Vector
capacity, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, removeAllElements, removeElement, removeElementAt, setElementAt, setSize, size, toString, trimToSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleSortingVector

public SimpleSortingVector()
Constructs a new SimpleSortingVector instance.
Method Detail

add

public void add(Object obj)
Deprecated. Use addElement(java.lang.Object) instead.

Adds provided object to this vector.

If this vector was set to sort dynamically, then this vector sorts itself after the addition.

Parameters:
obj - Object to add.

addElement

public void addElement(Object obj)
Adds provided object to this vector.

If this vector was set to sort dynamically, then this vector sorts itself after the addition.

Overrides:
addElement in class Vector
Parameters:
obj - Object to add.
Throws:
IllegalStateException - If a Comparator has not been set or is null.
Since:
JDE 4.2.0

find

public int find(Object key)
Find an object in the vector based on a given key.
Parameters:
key - Key to look for in the vector.
Returns:
If an object matching the given key exists in the vector (as determined by the comparator), the index of the matching element in the vector is returned. If a matching object could not be found, then -(insertionPoint + 1) is returned.
Throws:
IllegalStateException - If a Comparator has not been set or is null.

getAt

public Object getAt(int index)
Deprecated. Use Vector.elementAt(int) instead.

Retrieves element by index.
Parameters:
index - Index of element of retrieve.
Returns:
Object at provided index.

getVector

public Vector getVector()
Deprecated. SimpleSortingVector is now an instance of Vector

Retrieves this sorting vector's contents.

Invoke this method to retrieve this sorting vector's contents in Vector object.

Returns:
Vector of the same size as this sorting vector, containing a snapshot of this sorting vector's contents.

remove

public void remove(int index)
Deprecated. Use Vector.removeElementAt(int) instead.

Removes element by index.
Parameters:
index - Index of element to remove from this vector.

removeAll

public void removeAll()
Deprecated. Use Vector.removeAllElements() instead.

Flushes this vector.

This method removes all elements from the vector.


reSort

public void reSort()
Sorts this vector.
Throws:
IllegalStateException - If a Comparator has not been set or is null.

setSort

public boolean setSort(boolean toSort)
Specifies whether this vector should sort dynamically.
Parameters:
toSort - If true, this vector sorts as new elements are added, or when a new comparator is specified; if false, then you must manually invoke reSort() to sort this vector.
Returns:
True if vector was already set to dynamically sort; otherwise, false.
Throws:
IllegalStateException - If a Comparator has not been set or is null.

setSortComparator

public void setSortComparator(Comparator newComparator)
Sets a new comparator for use with this sorting vector.

If this vector is currently set to be sorted as elements are added, then this method also sorts the vector.

Parameters:
newComparator - New comparator to use when sorting this vector.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.