Package com.ibm.wala.util.collections
Class SparseVector<T>
- java.lang.Object
-
- com.ibm.wala.util.collections.SparseVector<T>
-
- All Implemented Interfaces:
IVector<T>,Serializable,Iterable<T>
public class SparseVector<T> extends Object implements IVector<T>, Serializable
AnIVectorimplementation 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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SparseVector()SparseVector(int initialSize, float expansion)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Tget(int x)intgetMaxIndex()IntIteratoriterateIndices()Iterator<T>iterator()voidperformVerboseAction()voidremove(int x)IntIteratorsafeIterateIndices()This iteration _will_ cover all indices even when remove is called while the iterator is active.voidset(int x, @Nullable T value)TODO: this can be optimizedintsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
get
@NullUnmarked public T get(int x)
- Specified by:
getin interfaceIVector<T>- See Also:
IntVector.get(int)
-
set
public void set(int x, @Nullable T value)TODO: this can be optimized- Specified by:
setin interfaceIVector<T>- See Also:
IntVector.set(int, int)
-
performVerboseAction
public void performVerboseAction()
- Specified by:
performVerboseActionin interfaceIVector<T>- See Also:
VerboseAction.performVerboseAction()
-
iterator
public Iterator<T> iterator()
- Specified by:
iteratorin interfaceIterable<T>- See Also:
IntSet.intIterator()
-
getMaxIndex
public int getMaxIndex() throws IllegalStateException- Specified by:
getMaxIndexin interfaceIVector<T>- Returns:
- max i s.t get(i) != null
- Throws:
IllegalStateException
-
size
public int size()
-
iterateIndices
public IntIterator iterateIndices()
-
safeIterateIndices
public IntIterator safeIterateIndices()
This iteration _will_ cover all indices even when remove is called while the iterator is active.
-
clear
public void clear()
-
remove
public void remove(int x)
-
-