Skip to content

Commit

Permalink
Group operations in the Dllist signature
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Jan 6, 2024
1 parent ee63d1f commit 5e731e2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/kcas_data/dllist_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module type Ops = sig
type ('x, 'fn) fn
type ('x, 'fn) blocking_fn

(** {2 Operations on nodes} *)

val remove : ('x, 'a node -> unit) fn
(** [remove n] removes the node [n] from the doubly-linked list it is part of.
[remove] is idempotent. *)
Expand All @@ -16,10 +18,14 @@ module type Ops = sig
(** [move_r n l] removes the node [n] from the doubly-linked list it is part
of and then adds it to the right of the list [l]. *)

(** {2 Operations on lists} *)

val is_empty : ('x, 'a t -> bool) fn
(** [is_empty l] determines whether the doubly-linked list [l] is empty or
not. *)

(** {3 Adding or removing values at the ends of a list} *)

val add_l : ('x, 'a -> 'a t -> 'a node) fn
(** [add_l v l] creates and returns a new node with the value [v] and adds the
node to the left of the doubly-linked list [l]. *)
Expand All @@ -46,6 +52,8 @@ module type Ops = sig
doubly-linked list [l], or blocks waiting for the list to become
non-empty. *)

(** {3 Moving all nodes between lists} *)

val swap : ('x, 'a t -> 'a t -> unit) fn
(** [swap l1 l2] exchanges the nodes of the doubly-linked lists [l1] and
[l2]. *)
Expand All @@ -58,6 +66,8 @@ module type Ops = sig
(** [transfer_r l1 l2] removes all nodes of [l1] and adds them to the right of
[l2]. *)

(** {3 Extracting all values or nodes from a list} *)

val to_list_l : ('x, 'a t -> 'a list) fn
(** [to_list_l l] collects the values of the nodes of the doubly-linked list
[l] to a list in left-to-right order.
Expand Down

0 comments on commit 5e731e2

Please sign in to comment.