Module GenMList
Efficient Mutable Lists
Unrolled lists, append-only, used for storing the content of a generator.
Example:
let g = 1 -- 1000 ;;
val g : int t = <fun>
let c = g |> MList.of_gen_lazy |> MList.to_clonable;;
val c : int clonable = <obj>
c#next |> take 500 |> to_list;;
- : int list = [1; 2; 3; .....; 500]
let c' = c#clone ;;
val c' : int clonable = <obj>
c |> to_list;;
- : int list = [501; 502; ....; 1000]
c'#gen |> to_list;; (* c consumed, but not c' *)
- : int list = [501; 502; ....; 1000]
c#gen |> to_list;;
- : int list = []- since
- 0.2.3
type 'a gen= unit -> 'a optiontype 'a clonable= < gen : 'a gen; clone : 'a clonable; >type 'a tAn internal append-only storage of elements of type 'a, produced from a generator
val of_gen_lazy : ?max_chunk_size:int -> ?caching:bool -> 'a gen -> 'a tof_gen_lazy gmakes a mlist that will read fromgas required, untilgis exhausted. Do not usegdirectly after this, or some elements will be absent from the mlist!- parameter caching
if true or absent, values are read from the generator by chunks of increasing size. If false, values are read one by one.
- parameter max_chunk_size
if provided and
caching = true, sets the (maximal) size of the internal chunks