package interval-map

  1. Overview
  2. Docs
An immutable interval map data structure

Install

dune-project
 Dependency

Authors

Maintainers

Sources

interval-map-0.2.1.tbz
sha256=194a9a3e5c032413edbd496af6c8cc2b534a56ae655bef24a26dda09ec587d88
sha512=d46f4d3af9b974daf4c21d8e766a5c706a9a4642ae86fee2ddb8e2bac1a68a4c7541e325ba9f22e1c3c81048965470078d73a6fb037c580d6f773afdb483bed6

Description

An immutable interval map data structure implemented as an interval tree. Based on jgblight/im_interval_tree.

Interval maps are great for finding intervals and their associated values which overlap a given interval. This interval map supports intervals with excluded, included, and unbounded bound ends. Multiple values may be associated with the same interval.

Added to opam-repository:

README

interval-map

Actions Status

Documentation

An immutable interval map data structure implemented as an interval tree. Based on jgblight/im_interval_tree.

Interval maps are great for finding intervals and their associated values which overlap a given interval. This interval map supports intervals with excluded, included, and unbounded bound ends. Multiple values may be associated with the same interval.

Installation

opam install interval-map

Usage

let module Ivl_map = Interval_map.Make (Int) in
let module Ivl = Ivl_map.Interval in
(* Build the map *)
let map =
  Ivl_map.empty
  |> Ivl_map.add (Ivl.create (Included 0) (Excluded 10)) "foo"
  |> Ivl_map.add (Ivl.create (Included 0) (Excluded 10)) "foo2"
  |> Ivl_map.add (Ivl.create (Excluded 0) (Included 10)) "bar"
  |> Ivl_map.add (Ivl.create (Included 5) (Included 10)) "baz"
  |> Ivl_map.add (Ivl.create (Excluded 4) (Excluded 10)) "oof"
  |> Ivl_map.add (Ivl.create Unbounded (Excluded 4)) "zab"
in

(* Query the map *)
let query = Ivl.create Unbounded (Included 4) in
Ivl_map.query_interval query map
|> Ivl_map.Query_results.to_list
(* Results:
  [({Ivl_map.Interval.low = Ivl_map.Bound.Unbounded; high = Ivl_map.Bound.Excluded 4},
    ["zab"]);
    ({Ivl_map.Interval.low = Ivl_map.Bound.Included 0; high = Ivl_map.Bound.Excluded 10},
    ["foo2", "foo"]);
    ({Ivl_map.Interval.low = Ivl_map.Bound.Excluded 0; high = Ivl_map.Bound.Included 10},
    ["bar"])]
  *)

Dependencies (2)

  1. ocaml >= "4.08.0"
  2. dune >= "3.0"

Dev Dependencies (2)

  1. odoc with-doc
  2. alcotest >= "1.4.0" & with-test

Used by (1)

  1. menhir-lsp >= "0.3.2"

Conflicts

None