public class SortedVector
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static char |
ASCENDING
Constant to set the ascending order.
|
protected int |
capacityIncrement
The amount by which the capacity of the vector is automatically
incremented when its size becomes greater than its capacity.
|
static char |
DESCENDING
Constant to set the descending order.
|
Constructor and Description |
---|
SortedVector()
Constructs an empty vector so that its internal data array
has size 10 and its standard capacity increment is
zero.
|
SortedVector(char order)
Constructs an empty vector so that its internal data array
has size 10 and its standard capacity increment is
zero.
|
SortedVector(int initialCapacity)
Constructs an empty vector with the specified initial capacity and
with its capacity increment equal to zero.
|
SortedVector(int initialCapacity,
char order)
Constructs an empty vector with the specified initial capacity and
with its capacity increment equal to zero.
|
SortedVector(int initialCapacity,
int capacityIncrement)
Constructs an empty vector with the specified initial capacity and
capacity increment.
|
SortedVector(int initialCapacity,
int capacityIncrement,
char order)
Constructs an empty vector with the specified initial capacity and
capacity increment.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(java.lang.Object obj)
Adds the specified element to the end of this Vector.
|
void |
addElement(java.lang.Object obj)
Adds the specified component to the end of this vector,
increasing its size by one.
|
java.lang.Comparable |
elementAt(int index)
Returns the component at the specified index.
|
java.lang.Object |
get(int index)
Returns the element at the specified position in this Vector.
|
boolean |
getDuplicate()
Get the duplicate flag.
|
char |
getOrder()
Get the sorting order.
|
void |
print(java.io.PrintStream out)
Print vector to print streem.
|
void |
setDuplicate(boolean dup)
Set the duplicate flag.
|
void |
setOrder(char order)
Set the sorting order.
|
int |
size()
Returns the number of components in this vector.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this Vector
in the correct order.
|
public static final char ASCENDING
public static final char DESCENDING
protected int capacityIncrement
0
, the capacity of the
vector is doubled each time it needs to grow.public SortedVector(int initialCapacity, int capacityIncrement, char order)
initialCapacity
- the initial capacity of the vector.capacityIncrement
- the amount by which the capacity is
increased when the vector overflows.order
- the order of the vector. Use the
predefined constants to specify it.
The default is ASCENDING.java.lang.IllegalArgumentException
- if the specified initial capacity
is negativepublic SortedVector(int initialCapacity, int capacityIncrement)
initialCapacity
- the initial capacity of the vector.capacityIncrement
- the amount by which the capacity is
increased when the vector overflows.java.lang.IllegalArgumentException
- if the specified initial capacity
is negativepublic SortedVector(int initialCapacity, char order)
initialCapacity
- the initial capacity of the vector.order
- the order of the vector. Use the
predefined constants to specify it.
The default is ASCENDING.java.lang.IllegalArgumentException
- if the specified initial capacity
is negativepublic SortedVector(int initialCapacity)
initialCapacity
- the initial capacity of the vector.java.lang.IllegalArgumentException
- if the specified initial capacity
is negativepublic SortedVector(char order)
order
- the order of the vector. Use the
predefined constants to specify it.
The default is ASCENDING.public SortedVector()
public java.lang.Object get(int index)
index
- index of element to return.java.lang.ArrayIndexOutOfBoundsException
- index is out of range (index
< 0 || index >= size()).public int size()
public java.lang.Object[] toArray()
public void setOrder(char order)
public char getOrder()
public boolean getDuplicate()
public void setDuplicate(boolean dup)
public void addElement(java.lang.Object obj)
This method is identical in functionality to the add(Object) method (which is part of the List interface).
obj
- the component to be added.add(Object)
,
List
public boolean add(java.lang.Object obj)
o
- element to be appended to this Vector.public java.lang.Comparable elementAt(int index) throws java.lang.ArrayIndexOutOfBoundsException
index
- an index into this vector.java.lang.ArrayIndexOutOfBoundsException
- if the index is negative or
not less than the current size
of this Vector object.public void print(java.io.PrintStream out)
out
- the print stream