|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.collection.util.BigLongVector
public class BigLongVector
Vector optimized to support insert/delete operations without shuffling the entire array.
The insert/delete operations are accomplished by sorting the elements in variable sized sub-arrays, or "chunks". Additionally, the underlying vector can be made contiguous for intensive operations, like sorting.
Constructor Summary | ||
---|---|---|
BigLongVector()
Constructs a new empty vector. |
||
BigLongVector(int initialCapacity)
Constructs a new empty vector with the specified initial capacity and chunk size. |
||
BigLongVector(int initialCapacity,
int chunkSize)
Constructs a new empty vector with the specified initial capacity and chunk size. |
Method Summary | ||
---|---|---|
void |
addElement(long obj)
Adds a new element to the end of this vector. |
|
void |
addElements(long[] array)
Adds a number of elements to the end of this vector. |
|
int |
binarySearch(long value)
Performs a binary search to locate a value. |
|
int |
copyInto(int offset,
int len,
long[] array,
int dstPosition)
Fills an array with elements from the vector. |
|
long |
elementAt(int index)
Retrieves element by index. |
|
int |
firstIndexOf(long value)
Finds first instance of value in list. |
|
long[] |
getContiguousArray()
Returns a contiguous array representation of this vector. |
|
void |
insertElementAt(long obj,
int index)
Inserts element at index. |
|
void |
insertElementsAt(long[] array,
int index)
Inserts a number of elements at index. |
|
boolean |
isEmpty()
Determines if this vector has no elements. |
|
void |
optimize()
Optimize this vector for fast element access by turning the underlying representation into a contiguous array. |
|
void |
removeAll()
Removes all this vector's elements. |
|
void |
removeElementAt(int index)
Deletes element by index. |
|
void |
setElementAt(long value,
int index)
Sets value of element by index. |
|
int |
size()
Returns the number of elements in this vector. |
|
void |
sort()
Sorts this vector in ascending integer order. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BigLongVector(int initialCapacity, int chunkSize)
initialCapacity
- Initial capacity of the vector.chunkSize
- Size of each chunk.public BigLongVector(int initialCapacity)
initialCapacity
- Initial capacity of the vector.public BigLongVector()
Method Detail |
---|
public int size()
public long[] getContiguousArray()
The underlying storage of the container can be a series of variable-sized sub-arrays, this method consolidates all of the storage into one array. The returned array should be treated as read-only, any modification of the array could disrupt the behaviour of the container.
public void optimize()
To improve this vector's performance, invoke this method after doing many insertions and/or deletions.
public boolean isEmpty()
public long elementAt(int index)
index
- Position of element to retrieve.
ArrayIndexOutOfBoundsException
- If invalid index.public int firstIndexOf(long value)
Note: this method does not use Object.equals(java.lang.Object)
for comparison, since
that would be too expensive. This method is still expensive, though, and you should use
it carefully and sparingly.
value
- Value to search for.
public void setElementAt(long value, int index)
This method replaces the existing value of the element with your new value.
value
- New value for element at index.index
- Index of element to change; must be at least 0 and less than the
size of this vector..
ArrayIndexOutOfBoundsException
- If invalid index.public void removeElementAt(int index)
This method removes the specified element from the vector, and shifts all elements beyond it back one slot.
index
- Index of element to remove; must be at least 0 and less than the
size of this vector.
ArrayIndexOutOfBoundsException
- If invalid index.public void removeAll()
public void insertElementAt(long obj, int index)
This method adds a new element at your specified index. The existing element at that position, and all elements beyond it, get shifted up one slot.
obj
- Element to insert.index
- Position new element should occupy; must be at least 0
and less than the size of this vector.
ArrayIndexOutOfBoundsException
- If invalid index.public void insertElementsAt(long[] array, int index)
This method adds a number of elements, the first at your specified index. The existing element at that position, and all the elements beyond it, are shifted up a number of slots equal to the size of the array inserted.
array
- Elements to insert.index
- Position new element should occupy; must be at least 0
and less than the size of this vector.
ArrayIndexOutOfBoundsException
- if the index was invalidpublic void addElement(long obj)
If needed, this vector's size increases by one.
obj
- Element to add.public void addElements(long[] array)
This vector's size increases as needed to include all the new elements.
array
- Elements to add.public int copyInto(int offset, int len, long[] array, int dstPosition)
dstPosition
.
offset
- The offset into the vector of the first element to be copied.len
- The number of elements to read from the vector.array
- The array to fill with the copied elements.dstPosition
- The position in the destination array at which to begin
storing the copied elements.
public int binarySearch(long value)
This method fails if this vector is not sorted in ascending integer order.
value
- Value to search for.
( -( insertPoint + 1 ) )
; the insert point is the position the
value would occupy in the vector.public void sort()
|
|||||||||
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.