TinyLine 2.3

com.tinyline.tiny2d
Class TinyVector

java.lang.Object
  extended by com.tinyline.tiny2d.TinyVector

public final class TinyVector
extends java.lang.Object

The TinyVector class implements a growable array of objects.

Version:
1.8

Field Summary
 int count
          The number of elements in this TinyVector object.
 java.lang.Object[] data
          The array buffer where the elements of the TinyVector are stored.
 
Constructor Summary
TinyVector(int i)
          Creates an empty vector with the specified initial capacity.
TinyVector(TinyVector src)
          Creates a new vector as a copy of the specified vector.
 
Method Summary
 void addElement(java.lang.Object obj)
          Adds the object to the end of this vector, increasing its size by one.
 int indexOf(java.lang.Object obj, int i)
          Searches for the first occurence of the given object, starting at i, and testing for equality using the equals method.
 int insertElementAt(java.lang.Object obj, int i)
          Inserts the object as an element in this vector at the specified index i.
 int lastIndexOf(java.lang.Object obj, int i)
          Searches backwards for the specified object, starting from the specified index, and returns an index to it.
 int removeElementAt(int i)
          Deletes the object at the specified index i.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

public int count
The number of elements in this TinyVector object. The elements are from data[0] through data[count-1].


data

public java.lang.Object[] data
The array buffer where the elements of the TinyVector are stored.

Constructor Detail

TinyVector

public TinyVector(int i)
Creates an empty vector with the specified initial capacity.

Parameters:
i - the initial capacity of the vector.

TinyVector

public TinyVector(TinyVector src)
Creates a new vector as a copy of the specified vector.

Parameters:
src - the vector to be copied.
Method Detail

addElement

public void addElement(java.lang.Object obj)
Adds the object to the end of this vector, increasing its size by one.

Parameters:
obj - the object to be added.

indexOf

public int indexOf(java.lang.Object obj,
                   int i)
Searches for the first occurence of the given object, starting at i, and testing for equality using the equals method.

Parameters:
obj - an object.
i - the non-negative index to start searching from.
Returns:
the index of the first occurrence of the object; returns -1 if the object is not found.
Throws:
java.lang.IndexOutOfBoundsException - if i is negative.

insertElementAt

public int insertElementAt(java.lang.Object obj,
                           int i)
Inserts the object as an element in this vector at the specified index i.

Parameters:
obj - the object to insert.
i - where to insert the object.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.

lastIndexOf

public int lastIndexOf(java.lang.Object obj,
                       int i)
Searches backwards for the specified object, starting from the specified index, and returns an index to it.

Parameters:
obj - the desired component.
i - the index to start searching from.
Returns:
the index of the last occurrence of the specified object; returns -1 if the object is not found.
Throws:
java.lang.IndexOutOfBoundsException - if i is greater than or equal to the current size of this vector.

removeElementAt

public int removeElementAt(int i)
Deletes the object at the specified index i.

Parameters:
i - the index of the object to remove.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.

TinyLine 2.3

Provided under the terms of the TinyLine License Agreement that has been included with this distribution.