sandmark.util
Class SparseVector
java.lang.Object
|
+--sandmark.util.SparseVector
- All Implemented Interfaces:
- java.lang.Cloneable
- public class SparseVector
- extends java.lang.Object
- implements java.lang.Cloneable
This is similar to java.util.Vector.
However,
- we count from 1;
- we ignore missing elements. So, get(i) will
return null rather than throw an exception if element
i does not exist;
- the vector grows automatically. So, whenever we try to
set(i,obj) the vector is grown to accomodate object
number i;
- When iterating over a vector we ignore (i.e. don't return)
null elements.
Field Summary |
(package private) java.util.Vector |
elements
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
elements
java.util.Vector elements
SparseVector
public SparseVector()
SparseVector
public SparseVector(int initialCapacity)
clone
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
- Overrides:
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
copy
public SparseVector copy()
get
public java.lang.Object get(int index)
set
public java.lang.Object set(int index,
java.lang.Object elmt)
size
public int size()
iterator
public java.util.Iterator iterator()