Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

marf.util
Class FreeVector  view FreeVector download FreeVector.java

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.Vector
              extended bymarf.util.FreeVector
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.lang.Iterable, java.util.List, java.util.RandomAccess, java.io.Serializable
Direct Known Subclasses:
Matrix

public class FreeVector
extends java.util.Vector

Adaptive extension of the java.util.Vector class.

You may access elements of a Vector beyond it's initial length --- the Vector will be automaticall adjusted as appropriate.

Useful in the applications where desirable vector's growth by setting an element beyond its upper boundary automatticaly lengthens the vector to accomondate the change (similar to Perl arrays).

Similarly, getting an element beyond the upper boundary is not desirable failure, but an empty element returned. This makes the application to see as vector of a theoretically infinite in length.

TODO: allow negative index boundaries. $Id: FreeVector.java,v 1.12 2005/08/11 00:44:50 mokhov Exp $

Since:
0.3.0.1
Version:
$Revision: 1.12 $

Nested Class Summary
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
private static long serialVersionUID
          For serialization versioning.
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
FreeVector()
          A free vector with default capacity as specified by java.util.Vector.
FreeVector(java.util.Collection poCollection)
          Constructs this vector out of a collection.
FreeVector(int piInitialCapacity)
          Constructs this vector given capacity other than default.
FreeVector(int piInitialCapacity, int piCapacityIncrement)
          Constructs this vector given capacity and its increment.
 
Method Summary
 void add(int piIndex, java.lang.Object poElement)
          Adds an element of the vector at the specified index.
 boolean addAll(int piIndex, java.util.Collection poCollection)
          Adds a collection of elements to this vector starting at given index.
 java.lang.Object elementAt(int piIndex)
          Access an element of the vector given index.
 void ensureIndexCapacity(int piIndex)
          Make sure the capacity of the vector is enough to hold an element with the specified index.
 java.lang.Object get(int piIndex)
          Access an element of the vector given index.
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 void insertElementAt(java.lang.Object poElement, int piIndex)
          Inserts an element of the vector after given index.
 java.lang.Object remove(int piIndex)
          Removes an element at index.
 void removeRange(int piFromIndex, int piToIndex)
          Not implemented.
 java.lang.Object set(int piIndex, java.lang.Object poElement)
          Set an element of the vector given index.
 void setElementAt(java.lang.Object poElement, int piIndex)
          Set an element of the vector given index.
 java.util.List subList(int piFromIndex, int piToIndex)
          Retrieves a sublist subset of vector elements given index boundaries.
 
Methods inherited from class java.util.Vector
add, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elements, ensureCapacity, equals, firstElement, hashCode, indexOf, indexOf, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAll, removeAllElements, removeElement, removeElementAt, retainAll, setSize, size, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.util.AbstractCollection
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

serialVersionUID

private static final long serialVersionUID
For serialization versioning. When adding new members or make other structural changes regenerate this number with the serialver tool that comes with JDK.

Since:
0.3.0.4
See Also:
Constant Field Values
Constructor Detail

FreeVector

public FreeVector()
A free vector with default capacity as specified by java.util.Vector.


FreeVector

public FreeVector(int piInitialCapacity)
Constructs this vector given capacity other than default. Inherited from java.util.Vector.


FreeVector

public FreeVector(int piInitialCapacity,
                  int piCapacityIncrement)
Constructs this vector given capacity and its increment. Inherited from java.util.Vector.


FreeVector

public FreeVector(java.util.Collection poCollection)
Constructs this vector out of a collection. Inherited from java.util.Vector.

Method Detail

elementAt

public java.lang.Object elementAt(int piIndex)
Access an element of the vector given index. Overridden from java.util.Vector.


setElementAt

public void setElementAt(java.lang.Object poElement,
                         int piIndex)
Set an element of the vector given index. Capacity is always ensured to be able to accomodate any positive inidex (barring out of memory problems). Overridden from java.util.Vector.


insertElementAt

public void insertElementAt(java.lang.Object poElement,
                            int piIndex)
Inserts an element of the vector after given index. Capacity is always ensured to be able to accomodate any positive inidex (barring out of memory problems). Overridden from java.util.Vector.


ensureIndexCapacity

public void ensureIndexCapacity(int piIndex)
Make sure the capacity of the vector is enough to hold an element with the specified index. Has effect only if the index is greater than the current vector's size.


get

public java.lang.Object get(int piIndex)
Access an element of the vector given index. Overridden from java.util.Vector. Calls the overridden elementAt().


set

public java.lang.Object set(int piIndex,
                            java.lang.Object poElement)
Set an element of the vector given index. Capacity is always ensured to be able to accomodate any positive inidex (barring out of memory problems). Overridden from java.util.Vector.


add

public void add(int piIndex,
                java.lang.Object poElement)
Adds an element of the vector at the specified index. Overridden from java.util.Vector. Calls the overridden insertElementAt().


remove

public java.lang.Object remove(int piIndex)
Removes an element at index. If the index is beyond the upper boundary, returns null. Overrides java.util.Vector.


addAll

public boolean addAll(int piIndex,
                      java.util.Collection poCollection)
Adds a collection of elements to this vector starting at given index. Makes sure the capacity of the current vector reaches the piIndex. Overrides java.util.Vector.


subList

public java.util.List subList(int piFromIndex,
                              int piToIndex)
Retrieves a sublist subset of vector elements given index boundaries. Makes sure the capacity of the current vector reaches the piToIndex. Overrides java.util.Vector.


removeRange

public void removeRange(int piFromIndex,
                        int piToIndex)
Not implemented. Meant to remove a set of elements between two specified indices.


getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Retrieves class' revision.

Since:
0.3.0.2