SparseVector
Compressed sparse vector: parallel indices/values arrays of equal length, each holding one nonzero entry. Immutable from the caller's perspective; to change the sparsity pattern, rebuild.
get is a linear scan rather than a binary search on purpose. Typical nnz is small (handful to a few hundred for sparse feature vectors from nominal-heavy CSPs), and at that scale a tight IntArray loop beats binary search's mispredicted branches and indirect indexing. Internal ops iterate via forEachStored and skip get entirely.
Indices are not required to be sorted; the constructor only checks the parallel- array invariant.
Types
Factory entrypoints for SparseVector.
Properties
Functions
Read entry at i. O(1) for DenseVector, O(nnz) linear scan for SparseVector. Use the internal forEachStored extension when you want to walk the populated entries without per-index lookup cost.
Materialise into a fresh dense DoubleArray. Always allocates; the returned array is independent of any internal storage, so the caller is free to mutate it.
equals
get
Read entry at i. O(1) for DenseVector, O(nnz) linear scan for SparseVector. Use the internal forEachStored extension when you want to walk the populated entries without per-index lookup cost.
hashCode
size
toDoubleArray
Materialise into a fresh dense DoubleArray. Always allocates; the returned array is independent of any internal storage, so the caller is free to mutate it.