org.itc.irst.tcc.sre.util
Class SparseVector

java.lang.Object
  extended by org.itc.irst.tcc.sre.util.SparseVector
All Implemented Interfaces:
Vector

public class SparseVector
extends java.lang.Object
implements Vector

TO DO

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

Nested Class Summary
 class SparseVector.Entry
           
private  class SparseVector.VectorIterator
           
 
Field Summary
private  int count
           
private  SparseVector.Entry head
           
(package private) static org.apache.log4j.Logger logger
          Define a static logger variable so that it references the Logger instance named SparseVector.
private  int size
           
private  SparseVector.Entry tail
           
 
Constructor Summary
SparseVector()
           
 
Method Summary
 void add(int index, double value)
          Inserts the specified element at the specified position in this vector.
 boolean check()
           
 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.
private  SparseVector.Entry find(int index)
          Returns the Entry specified by this index
 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.
static void main(java.lang.String[] args)
           
 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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
Define a static logger variable so that it references the Logger instance named SparseVector.


head

private SparseVector.Entry head

tail

private SparseVector.Entry tail

count

private int count

size

private int size
Constructor Detail

SparseVector

public SparseVector()
Method Detail

add

public void add(int index,
                double value)
         throws java.lang.IndexOutOfBoundsException
Description copied from interface: Vector
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).

Specified by:
add in interface Vector
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

public double get(int index)
           throws java.lang.IndexOutOfBoundsException
Description copied from interface: Vector
Returns the element at the specified position in this vector.

Specified by:
get in interface 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

public boolean existsIndex(int index)
Description copied from interface: Vector
Returns a boolean denoting whether this index already exists in the vector.

Specified by:
existsIndex in interface Vector
Parameters:
index - index of element to return.
Returns:
true if and only if the index exists; false otherwise

set

public void set(int index,
                double value)
         throws java.lang.IndexOutOfBoundsException
Description copied from interface: Vector
Replaces the element at the specified position in this vectro with the specified element (optional operation).

Specified by:
set in interface Vector
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

public int size()
Description copied from interface: Vector
Returns the size of this vector.

Specified by:
size in interface Vector
Returns:
the size of this vector.

elementCount

public int elementCount()
Description copied from interface: Vector
Returns the number of elements in this vector

Specified by:
elementCount in interface Vector
Returns:
the number of elements in this vector.

find

private SparseVector.Entry find(int index)
Returns the Entry specified by this index

Parameters:
index - index of element to return.
Returns:
an Entry if and only if the index exists; null otherwise

iterator

public java.util.Iterator iterator()
Description copied from interface: Vector
Returns an iterator over the elements in this vector in proper sequence.

Specified by:
iterator in interface Vector
Returns:
an iterator over the elements in this vector in proper sequence.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

dotProduct

public double dotProduct(Vector v)
Description copied from interface: Vector
Returns an iterator over the elements in this vector in proper sequence (optional operation).

Specified by:
dotProduct in interface Vector
Returns:
an iterator over the elements in this vector in proper sequence.

norm

public double norm()
Description copied from interface: Vector
Returns the norm of this vector (optional operation).

Specified by:
norm in interface Vector
Returns:
norm of this vector;

normalize

public void normalize()
Description copied from interface: Vector
Normalizes this vector (optional operation).

Specified by:
normalize in interface Vector

check

public boolean check()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception