You can also watch la4j CompressedVector . It uses a couple of arrays: an array of values ββand an array of their pointers. And with binary search on top of it, it just flies. Thus, this implementation guarantees O(log n) runtime for get / set operations.
Just a quick example
Vector a = new CompressedVector(new double[]{ 1.0, 2.0, 3.0 }).
source share