package mergeable-vector

  1. Overview
  2. Docs
On This Page
  1. Mergeable-vector
Legend:
Library
Module
Module type
Parameter
Class
Class type

Mergeable-vector

include Vector

Vector

type atom

The type of vector element.

type t

The type of vector.

val length : t -> int

Length of vector.

val set : t -> int -> atom -> t

set v i e updates the element at position i in v to e.

Raise Invalid_argument "index out of bounds" if i is outside the range 0 to length v - 1.

val get : t -> int -> atom

get v i returns the element at position i in v.

Raise Invalid_argument "index out of bounds" if i is outside the range 0 to length v - 1.

val insert : t -> int -> atom -> t

insert v i e inserts the element e at position i in v.

Raise Invalid_argument "index out of bounds" if i is outside the range 0 to length v.

val delete : t -> int -> t

delete v i deletes the element at position i in v.

Raise Invalid_argument "index out of bounds" if i is outside the range 0 to length v - 1.

type patch

The type of patch.

val diff : t -> t -> patch

diff a b returns a patch p such that apply a p = b. The difference is computed by Wagner-Fischer algorithm. O(length(a) * length(b)) time and space.

val apply : t -> patch -> t

apply a p applies the compatibe patch p on a.

Raise Invalid_argument "incompatible patch" if the patch cannot be applied.

val merge : resolve:(atom -> atom -> atom) -> ancestor:t -> t -> t -> t

merge r a l r performs a 3-way merge between two vectors l and r, and their common ancestor a. Merge conflicts are handled by the resolve function.