Class SparseVector<T>

  • All Implemented Interfaces:
    IVector<T>, java.io.Serializable, java.lang.Iterable<T>

    public class SparseVector<T>
    extends java.lang.Object
    implements IVector<T>, java.io.Serializable
    An 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.
    See Also:
    Serialized Form
    • Constructor Detail

      • SparseVector

        public SparseVector()
      • SparseVector

        public SparseVector​(int initialSize,
                            float expansion)
    • Method Detail

      • get

        public T get​(int x)
        Specified by:
        get in interface IVector<T>
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
      • getMaxIndex

        public int getMaxIndex()
                        throws java.lang.IllegalStateException
        Specified by:
        getMaxIndex in interface IVector<T>
        Returns:
        max i s.t get(i) != null
        Throws:
        java.lang.IllegalStateException
      • size

        public int size()
      • 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)