net.rim.device.api.util
Class SimpleSortingVector

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

public class SimpleSortingVector
extends Object

Simple sorting vector of objects.


Constructor Summary
SimpleSortingVector()
          Constructs a new SimpleSortingVector instance.
 
Method Summary
 void add(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)
          Retrieves element by index.
 Vector getVector()
          Retrieves this sorting vector's contents.
 void remove(int index)
          Removes element by index.
 void removeAll()
          Flushes this vector.
 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.
 int size()
          Retrieves the number of elements in this vector.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSortingVector

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

getVector

public Vector getVector()
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.

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.
Since:
JDE 4.0.2

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.
Since:
JDE 4.0.2

reSort

public void reSort()
Sorts this vector.

add

public void add(Object obj)
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.
Since:
JDE 4.0.2

getAt

public Object getAt(int index)
Retrieves element by index.
Parameters:
index - Index of element of retrieve.
Returns:
Object at provided index.
Since:
JDE 4.0.2

remove

public void remove(int index)
Removes element by index.
Parameters:
index - Index of element to remove from this vector.
Since:
JDE 4.0.2

removeAll

public void removeAll()
Flushes this vector.

This method removes all elements from the vector.


size

public int size()
Retrieves the number of elements in this vector.
Returns:
Number of elements in this vector.

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.
Since:
JDE 4.0.2


Copyright 1999-2004 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.