package miou

  1. Overview
  2. Docs
Composable concurrency primitives for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

miou-0.8.0.tbz
sha256=8cc05f77a23680a52a3008d461afed3b210c29c6cccdacd113232c41bab789fa
sha512=61bc945b1c8c15e65b927cae6837d18988d296f5797012acae5d245cc86be41c6fc3cf88ebe82670181acaaa1ed3f3b0648af63f8c768952bf4d834e5fa92bc2

doc/miou/Miou_sequence/index.html

Module Miou_sequenceSource

Mutable sequence of elements.

Sourcetype 'a t

Type of a sequence holding values of type 'a.

Sourcetype 'a node = private {
  1. mutable prev : 'a t;
  2. mutable next : 'a t;
  3. mutable data : 'a;
  4. mutable active : bool;
}

Type of a node holding one value of type 'a in a sequence.

NOTE: The user can deconstruct a node to avoid indirect access to values, but it is not advisable to modify the fields.

Sourcetype direction =
  1. | Right
  2. | Left
    (*

    Type of directions used by add and take.

    *)
Sourceexception Empty

Exception raised by take when the sequence is empty.

Sourceval create : unit -> 'a t

create () creates a new empty sequence.

Sourceval take : direction -> 'a t -> 'a

take direction t takes an element of t from the specified direction.

Sourceval peek_node : direction -> 'a t -> 'a node
Sourceval add : direction -> 'a t -> 'a -> unit

add direction t adds a new element into t to the specified direction.

Sourceval drop : 'a t -> unit

Removes all nodes from the given sequence. The nodes are not actually mutated to not their removal. Only the sequence's pointers are update.

Sourceval length : 'a t -> int

Returns the number of elements in the given sequence. This is a O(n) operation where n is the number of elements in the sequence.

Sourceval exists : ('a -> bool) -> 'a t -> bool
Sourceval iter : f:('a -> unit) -> 'a t -> unit

iter ~f s applies f on all elements of s starting from left.

Sourceval iter_node : f:('a node -> unit) -> 'a t -> unit

iter_node ~f s applies f on all nodes of s starting from left.

Sourceval is_empty : 'a t -> bool

Returns true iff the given sequence is empty.

Sourceval remove : 'a node -> unit

Removes a node from the sequence it is part of. It does nothing if the node has already been removed.

Sourceval data : 'a node -> 'a

Returns the contents of a node.

Sourceval to_list : 'a t -> 'a list

Returns the given sequence as a list.