package grenier

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Order_managed_intervalSource

Basic ordering operations

Sourcetype t

An element of an ordering.

Sourceval root : unit -> t

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

Sourceval 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.

Sourceval 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.

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

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

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

Compare two elements. O(1)

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

How many elements are ordered. O(1)

Memory management

Sourceval 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.

Sourceval 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

Sourceval unsafe_check : t -> string -> unit
OCaml

Innovation. Community. Security.