module RList:sig
..end
type 'a
p =
| |
I of |
(* | I (i, v) adds v at position i | *) |
| |
R of |
(* | R i removes i -th element | *) |
| |
U of |
(* | U (i, v) substitutes i -th element with v | *) |
| |
X of |
(* | X (i, j) swaps the i -th and j -th elements | *) |
type'a
patch ='a p list
The indices correspond to list contents after the operations that appear earlier in the list have been applied, not to the contents before the whole patch operation.
A patch comprised of I
, R
, and U
steps with increasing
indices can be applied in time O(m + n), where m is the patch
length and n is the current size of the list. (Arbitrary patches
are slower, requiring O(m * n).)
include ReactiveData.S
val cons : 'a -> 'a handle -> unit
val snoc : 'a -> 'a handle -> unit
val insert : 'a -> int -> 'a handle -> unit
insert v i h
adds v
as the i
-th position in the container
corresponding to h
. The indices of the subsequent elements
change.val remove : int -> 'a handle -> unit
remove i h
removes the i
-th position from the container
corresponding to h
. The indices of the subsequent elements
change.val update : 'a -> int -> 'a handle -> unit
update v i h
substitutes the i
-th element of the container
corresponding to h
with v
val move : int -> int -> 'a handle -> unit
move i j h
moves the i
-th element of the container
corresponding to h
to the j
-th position, modifying the
indices of other elementsval singleton : 'a -> 'a t
val singleton_s : 'a React.S.t -> 'a t
val concat : 'a t -> 'a t -> 'a t
concat a b
is the concatenation of a
and b
, and it gets
updated whenever a
and b
changeval rev : 'a t -> 'a t
rev a
is the reversal of a
; rev a
gets updated along with
a