package interval-map

  1. Overview
  2. Docs

Parameters

Signature

module Bound : sig ... end
module Interval : sig ... end
module Gen : sig ... end
type 'a t
val empty : 'a t

empty is an empty interval map.

val size : 'a t -> int

size map returns the number of values stored in the map. Multiple values may be stored with each interval, so the number of values is not necessarily the same as the number of intervals.

val cardinal : 'a t -> int

cardinal map is the same as size map

val add : Interval.t -> 'a -> 'a t -> 'a t

add interval value map adds value to map associated with interval. Not tail recursive.

val remove_by : Interval.t -> ('a -> bool) -> 'a t -> 'a t

remove_by interval value_rm_fn map removes all values associated with interval for which value_rm_fn returns true in map. Not tail recursive.

val remove_interval : Interval.t -> 'a t -> 'a t

remove_interval interval map removes the interval and all associated values from map. Not tail recursive.

val generator : ?order:order -> 'a t -> 'a Gen.t

generator order map creates a generator that traverses map. See Gen for generator API.

val fold : (Interval.t -> 'a list -> 'b -> 'b) -> 'a t -> 'b -> 'b

fold fn map acc folds over map applying function fn in ascending order of the intervals. fn takes the interval, values, and the accumulator as parameters and returns the updated accumulator. Tail recursive.

val mapi : (Interval.t -> 'a list -> 'b list) -> 'a t -> 'b t

mapi fn map builds a new interval map by applying fn to the elements in map. Elements are not traversed in order. Tail recursive.

val map : ('a list -> 'b list) -> 'a t -> 'b t

map fn map is like mapi but fn does not receive the interval. Tail recursive.

val iteri : (Interval.t -> 'a list -> unit) -> 'a t -> unit

iteri fn map applies fn to every element of the map in ascending order of the intervals. fn received both the interval and associated values and returns unit. Tail recursive.

val iter : ('a list -> unit) -> 'a t -> unit

iter fn map is like iteri but fn does not receive the interval. Tail recursive.

val to_list : 'a t -> (Interval.t * 'a list) list

to_list map converts map into a list where the elements of the resulting list are in ascending order by interval. Tail recursive.

val to_seq : 'a t -> (Interval.t * 'a list) Stdlib.Seq.t

to_seq map converts map into a Seq.t where the elements of the resulting seq are in ascending order by interval. Seqs are lazy so elements of the map are not traversed until the resulting seq is traversed.

val find_opt : Interval.t -> 'a t -> 'a list option

find_opt interval map finds all values associated with interval in map, or None if map does not contain interval. Tail recursive.

val find : Interval.t -> 'a t -> 'a list

find interval map finds all values associated with interval in map, or raises Not_found if map does not contain interval. Tail recursive.

val mem : Interval.t -> 'a t -> bool

mem interval map returns true if map contains interval, and false otherwise. Tail recursive.

val query_interval : ?order:order -> Interval.t -> 'a t -> 'a Gen.t

query_interval interval map finds all values associated with interval in the map. Results are provided as a generator, which traverses the map as results are read.

val query_interval_list : Interval.t -> 'a t -> (Interval.t * 'a list) list

query_interval interval map finds all values associated with interval in the map and returns the results as a list. Tail recursive.