package grenier
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=04831d5c2ea783d4e32b356a8495e5481ce8919aa70f5eecee29baebbf6fa483
sha512=1199122ab70701ecd33bf9c6339a743d163a1ba3ef5d0db189cab6c6712386739031b66002bf48d4740112430a93780f82dc37f56688ee33f99da928186b8205
doc/grenier.dbseq/Dbseq/index.html
Module DbseqSource
Dbseq immutable sequence
Dbseq is a small data structure that offers operations halfway between a list and an immutable array. Most operations have a logarithmic cost. In practice, it is a log with base 4 and small constant factors.
This data structure is particularly suitable to associate metadata to variables in De-Bruijn notation (hence the name).
Sequences with element of type 'a *
cons x xs adds element x at the beginning of sequence xs. x now has index 0 and xs's elements are shifted by 1. Worst-case cost is O(log n), though the actual cost is quasi constant.
get i xs access the i'th element of xs in cost O(log i). In particular, access to recent elements is quasi constant.
The operation is only defined if 0 <= i < length xs, and will raise Not_found if i is out of bounds.
set i x xs update the i'th element of xs to value x in cost O(log i).
The operation is only defined if 0 <= i < length xs, and will raise Not_found if i is out of bounds.
update xs i f behaves like set i (f (get i xs)) xs