org.itc.irst.tcc.sre.util
Interface Vector

All Known Implementing Classes:
SparseVector

public interface Vector

Interface for vectors holding double elements. A vector has a growable number of cells (its size). Elements are accessed via zero based indexes. Legal indexes are of the form [0..size()-1]. Any attempt to access an element at a coordinate index<0 || index>=size() will throw an IndexOutOfBoundsException.

Since:
1.0
Version:
%I%, %G%
Author:
Claudio Giuliano

Method Summary
 void add(int index, double value)
          Inserts the specified element at the specified position in this vector.
 double dotProduct(Vector v)
          Returns an iterator over the elements in this vector in proper sequence (optional operation).
 int elementCount()
          Returns the number of elements in this vector
 boolean existsIndex(int index)
          Returns a boolean denoting whether this index already exists in the vector.
 double get(int index)
          Returns the element at the specified position in this vector.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this vector in proper sequence.
 double norm()
          Returns the norm of this vector (optional operation).
 void normalize()
          Normalizes this vector (optional operation).
 void set(int index, double value)
          Replaces the element at the specified position in this vectro with the specified element (optional operation).
 int size()
          Returns the size of this vector.
 

Method Detail

add

void add(int index,
         double value)
         throws java.lang.IndexOutOfBoundsException
Inserts the specified element at the specified position in this vector. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
index - index at which the specified element is to be inserted.
value - value to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0).

get

double get(int index)
           throws java.lang.IndexOutOfBoundsException
Returns the element at the specified position in this vector.

Parameters:
index - index of element to return.
Returns:
the element at the specified position in this vector.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

existsIndex

boolean existsIndex(int index)
                    throws java.lang.IndexOutOfBoundsException
Returns a boolean denoting whether this index already exists in the vector.

Parameters:
index - index of element to return.
Returns:
true if and only if the index exists; false otherwise
Throws:
java.lang.IndexOutOfBoundsException

set

void set(int index,
         double value)
         throws java.lang.IndexOutOfBoundsException
Replaces the element at the specified position in this vectro with the specified element (optional operation).

Parameters:
index - index of element to return.
value - value to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

size

int size()
Returns the size of this vector.

Returns:
the size of this vector.

elementCount

int elementCount()
Returns the number of elements in this vector

Returns:
the number of elements in this vector.

iterator

java.util.Iterator iterator()
Returns an iterator over the elements in this vector in proper sequence.

Returns:
an iterator over the elements in this vector in proper sequence.

dotProduct

double dotProduct(Vector v)
Returns an iterator over the elements in this vector in proper sequence (optional operation).

Returns:
an iterator over the elements in this vector in proper sequence.

norm

double norm()
Returns the norm of this vector (optional operation).

Returns:
norm of this vector;

normalize

void normalize()
Normalizes this vector (optional operation).