Is there a good sparse/repetition array library?

78 views
Skip to first unread message

awaw...@gmail.com

unread,
Aug 17, 2026, 2:44:25 AM (yesterday) Aug 17
to golang-nuts
Hi fellow Gophers

I wonder does anyone know of a good sparse/repetition array library with the following features?

* Support repetitions and lengths of *big.Int. For example {12, 12, 12, ... repeat 10^129 times}...{327, 327, 327, ... repeat 10^178 times }..., total length 10^2048
* Support the usual slice indexing/subslice etc. operations, along with the `Index` and `Sort` methods in the slices package
* I need only 1-D arrays, so basically almost similar interface to the builtin slice data type
* Ideally clean and simple, with a single file implementation and a single file test.


I tried to look into the following libraries, but they don't quite seem to do what I want:


Further thinking on my above requirements seem to suggest what I am looking for is *not* what is commonly called "sparse vector" (whose repetitions are limited to zeros). However, I am not quite sure what to call my wanted data structure (I think what I have in mind should not be that esoteric, but alas could not find the search keyword).

Thanks 

Dan Kortschak

unread,
Aug 17, 2026, 4:23:28 AM (yesterday) Aug 17
to golan...@googlegroups.com
Not completely covering all the things you want, and good is
subjective, but there is my RLE package,
https://pkg.go.dev/github.com/biogo/store/step

It doesn't support sorting, but it should be too hard to extend for
that. I'm not sure of the efficiency of sorting, depending on the
complexity of the RL steps in the vector.

awaw...@gmail.com

unread,
Aug 17, 2026, 5:15:22 AM (yesterday) Aug 17
to golang-nuts
Thanks Dan, this package does seem like what I have been imagining, I'll take a closer at it.
Also, thanks for revealing that the keyword I am looking for is "run-length encoding", I am grateful for learning a new useful word. : )
Reply all
Reply to author
Forward
0 new messages