All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.core.FastVector

java.lang.Object
   |
   +----weka.core.FastVector

public class FastVector
extends Object
implements Copyable, Serializable
Implements a fast vector class without synchronized methods. Replaces java.util.Vector. (Synchronized methods tend to be slow.)

Version:
$Revision: 1.2 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)

Constructor Index

 o FastVector()
Constructs an empty vector with initial capacity zero.
 o FastVector(int)
Constructs a vector with the given capacity.
 o FastVector(int, int, double)
Constructs a vector with the given capacity, capacity increment and capacity mulitplier.

Method Index

 o addElement(Object)
Adds an element to this vector.
 o capacity()
Returns the capacity of the vector.
 o copy()
Produces a shallow copy of this vector.
 o copyElements()
Clones the vector and shallow copies all its elements.
 o elementAt(int)
Returns the element at the given position.
 o elements()
Returns an enumeration of this vector.
 o elements(int)
Returns an enumeration of this vector, skipping the element with the given index.
 o firstElement()
Returns the first element of the vector.
 o indexOf(Object)
Searches for the first occurence of the given argument, testing for equality using the equals method.
 o insertElementAt(Object, int)
Inserts an element at the given position.
 o lastElement()
Returns the last element of the vector.
 o removeAllElements()
Removes all components from this vector and sets its size to zero.
 o removeElementAt(int)
Deletes an element from this vector.
 o setCapacity(int)
Sets the vector's capacity to the given value.
 o setElementAt(Object, int)
Sets the element at the given index.
 o size()
Returns the vector's current size.
 o swap(int, int)
Swaps two elements in the vector.
 o trimToSize()
Sets the vector's capacity to its size.

Constructors

 o FastVector
 public FastVector()
Constructs an empty vector with initial capacity zero.

 o FastVector
 public FastVector(int capacity)
Constructs a vector with the given capacity.

Parameters:
capacity - the vector's initial capacity
 o FastVector
 public FastVector(int capacity,
                   int capIncrement,
                   double capMultiplier)
Constructs a vector with the given capacity, capacity increment and capacity mulitplier.

Parameters:
capacity - the vector's initial capacity

Methods

 o addElement
 public final void addElement(Object element)
Adds an element to this vector. Increases its capacity if its not large enough.

Parameters:
element - the element to add
 o capacity
 public final int capacity()
Returns the capacity of the vector.

Returns:
the capacity of the vector
 o copy
 public final Object copy()
Produces a shallow copy of this vector.

Returns:
the new vector
 o copyElements
 public final Object copyElements()
Clones the vector and shallow copies all its elements. The elements have to implement the Copyable interface.

Returns:
the new vector
 o elementAt
 public final Object elementAt(int index)
Returns the element at the given position.

Parameters:
index - the element's index
Returns:
the element with the given index
 o elements
 public final Enumeration elements()
Returns an enumeration of this vector.

Returns:
an enumeration of this vector
 o elements
 public final Enumeration elements(int index)
Returns an enumeration of this vector, skipping the element with the given index.

Parameters:
index - the element to skip
Returns:
an enumeration of this vector
 o firstElement
 public final Object firstElement()
Returns the first element of the vector.

Returns:
the first element of the vector
 o indexOf
 public final int indexOf(Object element)
Searches for the first occurence of the given argument, testing for equality using the equals method.

Parameters:
element - the element to be found
Returns:
the index of the first occurrence of the argument in this vector; returns -1 if the object is not found
 o insertElementAt
 public final void insertElementAt(Object element,
                                   int index)
Inserts an element at the given position.

Parameters:
element - the element to be inserted
index - the element's index
 o lastElement
 public final Object lastElement()
Returns the last element of the vector.

Returns:
the last element of the vector
 o removeElementAt
 public final void removeElementAt(int index)
Deletes an element from this vector.

Parameters:
index - the index of the element to be deleted
 o removeAllElements
 public final void removeAllElements()
Removes all components from this vector and sets its size to zero.

 o setCapacity
 public final void setCapacity(int capacity)
Sets the vector's capacity to the given value.

Parameters:
capacity - the new capacity
 o setElementAt
 public final void setElementAt(Object element,
                                int index)
Sets the element at the given index.

Parameters:
element - the element to be put into the vector
index - the index at which the element is to be placed
 o size
 public final int size()
Returns the vector's current size.

Returns:
the vector's current size
 o swap
 public final void swap(int first,
                        int second)
Swaps two elements in the vector.

Parameters:
first - index of the first element
second - index of the second element
 o trimToSize
 public final void trimToSize()
Sets the vector's capacity to its size.


All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home