|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.util.IntVector
net.rim.device.api.util.SimpleSortingIntVector
public class SimpleSortingIntVector
Simple sorting vector of integers.
Field Summary | ||
---|---|---|
static short |
SORT_TYPE_COMPARISON
sort using a comparator |
|
static short |
SORT_TYPE_NONE
not sorted |
|
static short |
SORT_TYPE_NUMERIC
sort numerically |
Fields inherited from class net.rim.device.api.util.IntVector |
---|
capacityIncrement, elementCount, elementData |
Constructor Summary | ||
---|---|---|
SimpleSortingIntVector()
Constructs a new SimpleSortingIntVector instance. |
||
SimpleSortingIntVector(int initialCapacity)
Constructs an empty vector with the specified initial capacity. |
||
SimpleSortingIntVector(int initialCapacity,
int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity increment. |
Method Summary | ||
---|---|---|
void |
addElement(int obj)
Adds provided object to this vector. |
|
int |
bestGuessBinarySearch(int object)
A bi-directional search that uses a binary search to guess the general vicinity of the required object, then branches out in either direction to find the exact object. |
|
int |
binarySearch(int obj,
short sortType)
Performs a binary search find the Object. |
|
short |
getSortState()
Retrieves this Vector's current sort state. |
|
int |
linearSearch(int obj)
Performs a linear search to find the Object. |
|
void |
reSort(short sortType)
Sorts this vector using the supplied comparator |
|
boolean |
removeElement(int obj)
Optimized removeElement() method. |
|
boolean |
setSortAsAdded(short sortType)
Set the option to sort this vector as elements are added |
|
void |
setSortComparator(IntComparator newComparator,
boolean sortNow,
boolean uniqueValueComparator)
Sets a new comparator for use with this sorting vector. |
Methods inherited from class net.rim.device.api.util.IntVector |
---|
capacity, contains, copyInto, elementAt, ensureCapacity, firstElement, getArray, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, removeAllElements, removeElementAt, setElementAt, setSize, size, toArray, trimToSize |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short SORT_TYPE_NUMERIC
public static final short SORT_TYPE_COMPARISON
public static final short SORT_TYPE_NONE
Constructor Detail |
---|
public SimpleSortingIntVector()
public SimpleSortingIntVector(int initialCapacity)
initialCapacity
- the initial capacity of the vector.public SimpleSortingIntVector(int initialCapacity, int capacityIncrement)
initialCapacity
- - the initial capacity of the vector.capacityIncrement
- - the amount by which the capacity is
increased when the vector overflows.Method Detail |
---|
public short getSortState()
SimpleSortingIntVector.setSortAsAdded(short)
.
SORT_TYPE_
constants defined in this class; the return value is
undefined in this vector is empty or if no elements have been added since
the last invocation of setSortAsAdded()
.public void setSortComparator(IntComparator newComparator, boolean sortNow, boolean uniqueValueComparator)
If this vector is currently set to be sorted as elements are added, then this method also sorts the vector.
newComparator
- New comparator to use when sorting this vector.sortNow
- True to sort array immediately using this comparatoruniqueValueComparator
- True if the comparison is done on a unique value, if true this will optimize element operations
NullPointerException
- If the newComparator parameter is null.public boolean setSortAsAdded(short sortType)
sortType
- Sort Type that should happen as elements are added,
default: SORT_TYPE_NONE (not sorted)
public void reSort(short sortType)
sortType
- How to sort this vector, one of SORT_TYPE_*public void addElement(int obj)
If this vector was set to sort dynamically, then this vector sorts itself after the addition.
addElement
in class IntVector
obj
- Object to add.public boolean removeElement(int obj)
removeElement
in class IntVector
obj
- Object to be delete
public int binarySearch(int obj, short sortType)
obj
- Object to find
IllegalStateException
- if the sort type is SORT_TYPE_NONE.public int bestGuessBinarySearch(int object)
IllegalStateException
- if sortType is not SORT_TYPE_COMPARISON.public int linearSearch(int obj)
obj
- Object To Find
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 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. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.