|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.util.ByteVector
public class ByteVector
Vector-like class for storing byte values. Note that this implementation is not synchronized. If multiple threads access this object concurrently, and at least one of the threads modifies the object, it must be synchronized externally.
Field Summary | ||
---|---|---|
protected int |
capacityIncrement
The amount by which the capacity of the vector is automatically incremented when its size becomes greater than its capacity. |
|
protected int |
elementCount
The number of valid components in the vector. |
|
protected byte[] |
elementData
The array buffer into which the components of the vector are stored. |
Constructor Summary | ||
---|---|---|
ByteVector()
Constructs an empty vector. |
||
ByteVector(int initialCapacity)
Constructs an empty vector with the specified initial capacity. |
||
ByteVector(int initialCapacity,
int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity increment. |
Method Summary | ||
---|---|---|
void |
addElement(byte obj)
Adds the specified component to the end of this vector, increasing its size by one. |
|
int |
capacity()
Returns the current capacity of this vector. |
|
boolean |
contains(byte elem)
Tests if the specified element is a component in this vector. |
|
void |
copyInto(byte[] anArray)
Copies the components of this vector into the specified array. |
|
byte |
elementAt(int index)
Returns the component at the specified index. |
|
void |
ensureCapacity(int minCapacity)
Increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument. |
|
byte |
firstElement()
Returns the first component of this vector. |
|
byte[] |
getArray()
Retrieves the vector values. |
|
int |
indexOf(byte elem)
Searches for the first occurence of the given argument, testing for equality. |
|
int |
indexOf(byte elem,
int index)
Searches for the first occurence of the given argument, beginning the search at index . |
|
void |
insertElementAt(byte obj,
int index)
Inserts the specified element as a component in this vector at the specified index . |
|
boolean |
isEmpty()
Tests if this vector has no components. |
|
byte |
lastElement()
Returns the last component of the vector. |
|
int |
lastIndexOf(byte elem)
Returns the index of the last occurrence of the specified element in this vector. |
|
int |
lastIndexOf(byte elem,
int index)
Searches backwards for the specified element, starting from the specified index, and returns an index to it. |
|
void |
removeAllElements()
Removes all components from this vector and sets its size to zero. |
|
boolean |
removeElement(byte obj)
Removes the first occurrence of the argument from this vector. |
|
void |
removeElementAt(int index)
Deletes the component at the specified index. |
|
void |
setElementAt(byte obj,
int index)
Sets the component at the specified index of this
vector to be the specified element. |
|
void |
setSize(int newSize)
Sets the size of this vector. |
|
int |
size()
Returns the number of components in this vector. |
|
byte[] |
toArray()
Retrieves a copy of the underlying store. |
|
void |
trimToSize()
Trims the capacity of this vector to be the vector's current size. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected byte[] elementData
protected int elementCount
protected int capacityIncrement
0
, the capacity of the
vector is doubled each time it needs to grow.
Constructor Detail |
---|
public ByteVector(int initialCapacity, int capacityIncrement)
initialCapacity
- the initial capacity of the vector.capacityIncrement
- the amount by which the capacity is
increased when the vector overflows.
IllegalArgumentException
- if the specified initial capacity
is negativepublic ByteVector(int initialCapacity)
initialCapacity
- the initial capacity of the vector.public ByteVector()
Method Detail |
---|
public void copyInto(byte[] anArray)
anArray
- the array into which the components get copied.public byte[] toArray()
public byte[] getArray()
public void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacity.public void setSize(int newSize)
newSize
and greater are discarded.
If a negative number is set as input, the function throws IllegalArgumentException.
newSize
- the new size of this vector.
IllegalArgumentException
- if the specified new size
is negativepublic int capacity()
public int size()
public boolean isEmpty()
true
if this vector has no components;
false
otherwise.public boolean contains(byte elem)
elem
- the desired component.
true
if the specified element is a component in
this vector; false
otherwise.public int indexOf(byte elem)
elem
- the desired component.
-1
if the element is not found.public int indexOf(byte elem, int index)
index
.
elem
- the desired component.index
- the index to start searching from.
index
or later in the
vector; returns -1
if the element is not found.public int lastIndexOf(byte elem)
elem
- the desired component.
-1
if the element is not found.public int lastIndexOf(byte elem, int index)
elem
- the desired component.index
- the index to start searching from.
index
or earlier in the vector;
-1
if the element is not found.public byte elementAt(int index)
index
- an index into this vector.
ArrayIndexOutOfBoundsException
- if an invalid index was
given.public byte firstElement()
NoSuchElementException
- if this vector has no components.public byte lastElement()
size() - 1
.
NoSuchElementException
- if this vector is empty.public void setElementAt(byte obj, int index)
index
of this
vector to be the specified element. The previous component at that
position is discarded.
The index must be a value greater than or equal to 0
and less than the current size of the vector.
obj
- what the component is to be set to.index
- the specified index.
ArrayIndexOutOfBoundsException
- if the index was invalid.public void removeElementAt(int index)
index
is shifted downward to have an index one
smaller than the value it had previously.
The index must be a value greater than or equal to 0
and less than the current size of the vector.
index
- the index of the element to remove.
ArrayIndexOutOfBoundsException
- if the index was invalid.public void insertElementAt(byte obj, int index)
index
. Each component in this vector with
an index greater or equal to the specified index
is
shifted upward to have an index one greater than the value it had
previously.
The index must be a value greater than or equal to 0
and less than or equal to the current size of the vector.
obj
- the component to insert.index
- where to insert the new component.
ArrayIndexOutOfBoundsException
- if the index was invalid.public void addElement(byte obj)
obj
- the component to be added.public boolean removeElement(byte obj)
obj
- the component to be removed.
true
if the argument was a component of this
vector; false
otherwise.public void removeAllElements()
|
|||||||||
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.