Module Interval_map.Make
Parameters
Signature
module Bound : sig ... end
module Interval : sig ... end
module Gen : sig ... end
val empty : 'a t
empty
is an empty interval map.
val size : 'a t -> int
size map
returns the number of values stored in themap
. 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 assize map
val add : Interval.t -> 'a -> 'a t -> 'a t
add interval value map
addsvalue
tomap
associated withinterval
. 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 withinterval
for whichvalue_rm_fn
returns true inmap
. Not tail recursive.
val remove_interval : Interval.t -> 'a t -> 'a t
remove_interval interval map
removes the interval and all associated values frommap
. Not tail recursive.
val generator : ?order:order -> 'a t -> 'a Gen.t
generator order map
creates a generator that traversesmap
. SeeGen
for generator API.
val fold : (Interval.t -> 'a list -> 'b -> 'b) -> 'a t -> 'b -> 'b
fold fn map acc
folds overmap
applying functionfn
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 applyingfn
to the elements inmap
. Elements are not traversed in order. Tail recursive.
val map : ('a list -> 'b list) -> 'a t -> 'b t
map fn map
is likemapi
butfn
does not receive the interval. Tail recursive.
val iteri : (Interval.t -> 'a list -> unit) -> 'a t -> unit
iteri fn map
appliesfn
to every element of the map in ascending order of the intervals.fn
received both the interval and associated values and returnsunit
. Tail recursive.
val iter : ('a list -> unit) -> 'a t -> unit
iter fn map
is likeiteri
butfn
does not receive the interval. Tail recursive.
val to_list : 'a t -> (Interval.t * 'a list) list
to_list map
convertsmap
into alist
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
convertsmap
into aSeq.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 withinterval
inmap
, orNone
ifmap
does not containinterval
. Tail recursive.
val find : Interval.t -> 'a t -> 'a list
find interval map
finds all values associated withinterval
inmap
, or raisesNot_found
ifmap
does not containinterval
. Tail recursive.
val mem : Interval.t -> 'a t -> bool
mem interval map
returnstrue
ifmap
containsinterval
, andfalse
otherwise. Tail recursive.
val query_interval : ?order:order -> Interval.t -> 'a t -> 'a Gen.t
query_interval interval map
finds all values associated withinterval
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 withinterval
in the map and returns the results as a list. Tail recursive.