CCRALRandom-Access Lists
This is an OCaml implementation of Okasaki's paper "Purely Functional Random Access Lists". It defines a list-like data structure with O(1) cons/tail operations, and O(log(n)) lookup/modification operations.
This module used to be part of containers.misc
status: stable
val empty : 'a tEmpty list.
val is_empty : _ t -> boolCheck whether the list is empty.
val return : 'a -> 'a tSingleton.
val hd : 'a t -> 'aFirst element of the list, or
val length : 'a t -> intNumber of elements. Complexity O(ln n) where n=number of elements.
val get : 'a t -> int -> 'a optionget l i accesses the i-th element of the list. O(log(n)).
get_and_remove_exn l i accesses and removes the i-th element of l.
take_drop n l splits l into a, b such that length a = n if length l >= n, and such that append a b = l.
val iter : f:('a -> unit) -> 'a t -> unitIterate on the list's elements.
val iteri : f:(int -> 'a -> unit) -> 'a t -> unitval fold : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'bFold on the list's elements.
val fold_rev : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'bFold on the list's elements, in reverse order (starting from the tail).
val make : int -> 'a -> 'a tval range : int -> int -> int trange i j is i; i+1; ... ; j or j; j-1; ...; i.
val of_list : 'a list -> 'a tConvert a list to a RAL. Caution: non tail-rec.
val to_list : 'a t -> 'a listval of_array : 'a array -> 'a tval to_array : 'a t -> 'a arrayMore efficient than on usual lists.
module Infix : sig ... end