public class SparseVector<T> extends Object implements IVector<T>, Serializable
IVector
implementation designed for low occupancy. Note that get() from this
vector is a binary search.
This should only be used for small sets ... insertion and deletion are linear
in size of set.Constructor and Description |
---|
SparseVector() |
SparseVector(int initialSize,
float expansion) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
T |
get(int x) |
int |
getMaxIndex() |
IntIterator |
iterateIndices() |
Iterator<T> |
iterator() |
void |
performVerboseAction() |
void |
remove(int x) |
IntIterator |
safeIterateIndices()
This iteration _will_ cover all indices even when remove is called while
the iterator is active.
|
void |
set(int x,
T value)
TODO: this can be optimized
|
int |
size() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public SparseVector()
public SparseVector(int initialSize, float expansion)
initialSize
- expansion
- public void set(int x, T value)
set
in interface IVector<T>
IntVector.set(int, int)
public void performVerboseAction()
performVerboseAction
in interface IVector<T>
public int getMaxIndex() throws IllegalStateException
getMaxIndex
in interface IVector<T>
IllegalStateException
public int size()
public IntIterator iterateIndices()
public IntIterator safeIterateIndices()
public void clear()
public void remove(int x)