Class Vector
All Packages Class Hierarchy This Package Previous Next Index
Class Vector
public class netscape.util.Vector
extends java.lang.Object
implements java.lang.Cloneable,
netscape.util.Codable
{
/* Constructors
*/
public Vector();
public Vector(int);
/* Methods
*/
public void addElement(Object);
public void addElementIfAbsent(Object);
public void addElements(Vector);
public void addElementsIfAbsent(Vector);
public int capacity();
public Object clone();
public boolean contains(Object);
public boolean containsIdentical(Object);
public void copyInto(Object[]);
public int count();
public void decode(Decoder);
public void describeClassInfo(ClassInfo);
public Object[] elementArray();
public Object elementAt(int);
public Enumeration elements();
public Enumeration elements(int);
public void encode(Encoder);
public void ensureCapacity(int);
public void finishDecoding();
public Object firstElement();
public int indexOf(Object);
public int indexOf(Object, int);
public int indexOfIdentical(Object, int);
public int indexOfIdentical(Object);
public boolean insertElementAfter(Object, Object);
public void insertElementAt(Object, int);
public boolean insertElementBefore(Object, Object);
public boolean isEmpty();
public Object lastElement();
public int lastIndexOf(Object);
public int lastIndexOf(Object, int);
public void removeAll(Object);
public void removeAllElements();
public boolean removeElement(Object);
public Object removeElementAt(int);
public boolean removeElementIdentical(Object);
public Object removeFirstElement();
public Object removeLastElement();
public Object replaceElementAt(int, Object);
public void setElementAt(Object, int);
public int size();
public void sort(boolean);
public void sortStrings(boolean, boolean);
public String toString();
public void trimToSize();
}
Object subclass that manages an array of objects). A Vector cannot contain
null.
Constructors
Vector
public Vector()
- Constructs a Vector with an initial capacity of 8 elements.
Vector
public Vector(int initialCapacity)
- Primitive constructor. Constructs a Vector large enough to hold
initialCapacity elements. The Vector will grow to accomodate
additional objects, as needed.
Methods
clone
public Object clone()
- Clones the Vector. Does not clone its elements.
- Overrides:
- clone in class Object
count
public int count()
- Returns the number of elements in the Vector.
size
public int size()
- Returns the number of elements in the Vector.
isEmpty
public boolean isEmpty()
- Returns true if the Vector contains no elements.
addElementIfAbsent
public void addElementIfAbsent(Object element)
- Adds element as the last element of the Vector, if not already
present within the Vector. Throws a NullPointerException if
element is null.
insertElementBefore
public boolean insertElementBefore(Object element,
Object existingElement)
- Inserts element before existingElement in the Vector.
If existingElement is null or cannot be found, this
method does nothing and returns false, otherwise it returns
true. This method throws a NullPointerException if
element is null.
insertElementAfter
public boolean insertElementAfter(Object element,
Object existingElement)
- Inserts element after existingElement in the Vector.
If existingElement is null or cannot be found, this
method does nothing and returns false, otherwise it returns
true. This method throws a NullPointerException if
element is null.
addElementsIfAbsent
public void addElementsIfAbsent(Vector aVector)
- Adds the elements contained in aVector that are not already
present in the Vector to the end of the Vector.
addElements
public void addElements(Vector aVector)
- Adds the elements contained in aVector to the end of the Vector.
removeAll
public void removeAll(Object element)
- Removes all occurrences of element from the Vector.
removeFirstElement
public Object removeFirstElement()
- Removes and returns the element at index 0, or null if the
Vector is empty.
removeLastElement
public Object removeLastElement()
- Removes and returns the element at index count() - 1 (the last object)
or null if the Vector is empty.
replaceElementAt
public Object replaceElementAt(int index,
Object element)
- Replaces the element at index with element. Returns
the replaced object. This method throws a NullPointerException if
element is null, and throws an
ArrayIndexOutOfBoundsException if index is an illegal index
value.
elementArray
public Object[] elementArray()
- Returns an array containing the Vector's contents.
copyInto
public void copyInto(Object anArray[])
- Copies the Vector's elements into anArray. This array must be
large enough to contain the elements.
trimToSize
public void trimToSize()
- Minimizes the Vector's storage area.
ensureCapacity
public void ensureCapacity(int minCapacity)
- Increases, if necessary, the the Vector's storage area so that it can
contain minCapacity elements.
capacity
public int capacity()
- Returns the number of elements that can be stored in the Vector
without increasing the Vector's storage area.
elements
public Enumeration elements()
- Returns an Enumeration that can be used to iterate through all of the
Vector's elements.
elements
public Enumeration elements(int index)
- Returns an Enumeration that can be used to iterate through the vector's
elements beginning at element index.
contains
public boolean contains(Object element)
- Returns true if the Vector contains element. The
comparison is performed using equals() with each element.
containsIdentical
public boolean containsIdentical(Object element)
- Returns true if the Vector contains element. The
comparison is performed using the == operator with each element.
indexOf
public int indexOf(Object element)
- Returns the index of element in the Vector. Returns -1
if the element is not present. The comparison is performed using
equals() with each element.
indexOf
public int indexOf(Object element,
int index)
- Returns the index of element in the Vector, starting at
index. Returns -1 if the element is not present.
The comparison is performed using equals() with each element.
indexOfIdentical
public int indexOfIdentical(Object element,
int index)
- Returns the index of element in the Vector, starting at
index. Returns -1 if the element is not present.
The comparison is performed using the == operator
with each element.
indexOfIdentical
public int indexOfIdentical(Object element)
- Returns the index of element in the Vector. Returns -1
if the element is not present. The comparison is performed using the
== operator with each element.
lastIndexOf
public int lastIndexOf(Object element)
- Returns the last index of element in the Vector. Returns
-1 if the element is not present. The comparison is performed
using equals() with each element.
lastIndexOf
public int lastIndexOf(Object element,
int index)
- Returns the last index of element in the vector, starting at
index. Returns -1 if the element is not present. The
comparison is performed using equals() with each element.
elementAt
public Object elementAt(int index)
- Returns the element at index.
firstElement
public Object firstElement()
- Returns the Vector's first element.
lastElement
public Object lastElement()
- Returns the Vector's last element.
setElementAt
public void setElementAt(Object element,
int index)
- Sets the element at index to element. This method throws
a NullPointerException if element is null, and throws an
ArrayIndexOutOfBoundsException if index is an illegal index
value.
removeElementAt
public Object removeElementAt(int index)
- Removes the element at index. This method throws an
ArrayIndexOutOfBoundsException if index is an illegal index
value.
insertElementAt
public void insertElementAt(Object element,
int index)
- Inserts element into the Vector at index. This method
throws a NullPointerException if element is null, and
throws an ArrayIndexOutOfBoundsException if index is an illegal
index value.
addElement
public void addElement(Object element)
- Adds element to the end of the vector. This method throws a
NullPointerException if element is null.
removeElement
public boolean removeElement(Object element)
- Removes the first occurrence of element from the Vector. The
comparison is performed using equals() with each element.
removeElementIdentical
public boolean removeElementIdentical(Object element)
- Removes the first occurrence of element from the vector. The
comparison is done using == with each element.
removeAllElements
public void removeAllElements()
- Empties the Vector, but leaves its capacity unchanged.
sort
public void sort(boolean ascending)
- Sorts the Vector's contents. Throws a ClassCastException if the
Vector's contents are not all Strings, or are not Comparable. String
comparisons are case sensitive.
sortStrings
public void sortStrings(boolean ascending,
boolean ignoreCase)
- Sorts the Vector's contents. Throws a ClassCastException if the
Vector's contents are not all Strings. If ignoreCase is
true, this method converts the Strings to upper case and then
compared.
toString
public String toString()
- Returns the Vector's string representation.
- Overrides:
- toString in class Object
describeClassInfo
public void describeClassInfo(ClassInfo info)
- Describes the Vector class' information.
- See Also:
- describeClassInfo
encode
public void encode(Encoder encoder) throws CodingException
- Encodes the Vector instance.
- See Also:
- encode
decode
public void decode(Decoder decoder) throws CodingException
- Decodes the Vector instance.
- See Also:
- decode
finishDecoding
public void finishDecoding() throws CodingException
- Finishes the Vector's decoding.
- See Also:
- finishDecoding
All Packages Class Hierarchy This Package Previous Next Index