package grenier

  1. Overview
  2. Docs
A collection of various algorithms in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

grenier-0.14.tbz
sha256=e5362e6ad0e888526517415e78b9e8243bb0cc1b0c952201884148832ac4442f
sha512=4e2f16b52b3c2786a1b8e93156184fd69d448cea571ca839b6cb88ab73f380994d1561fe24c1523c43ed8fc42d2ac01b673a13b6151fff4af4f009923d3aaf37

doc/grenier.orderme/Order_managed_interval/index.html

Module Order_managed_interval

Basic ordering operations

type t

An element of an ordering.

val root : unit -> t

Create a new ordering with a single element. O(1)

val after : t -> t

after t inserts a new element to the ordering, greater than t but less than all existing elements greater than t.

O(1) amortized.

val before : t -> t

before t inserts a new element to the ordering, less than t but greater than all existing elements less than t.

O(1) amortized.

val inside : t -> t
val outside : t -> t
val same_order : t -> t -> bool

Check if two elements belong to the same order. O(1)

type rel =
  1. | Before
  2. | Inside
  3. | Equal
  4. | Outside
  5. | After

Compare two elements. O(1)

val compare : t -> t -> rel
val cardinal : t -> int

How many elements are ordered. O(1)

Memory management

val forget : t -> unit

When you know you are not going to use an element any longer, forget it to release memory. It makes operations slightly faster to not have to wait for the GC to release elements.

val is_valid : t -> bool

After calling forget, an element should not be used. You can check if it is the case with is_valid.

Algorithm due to: Two Simplified Algorithms for Maintaining Order in a List Bender et al., 2002

val unsafe_check : t -> string -> unit
OCaml

Innovation. Community. Security.