package containers

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

Module CCIntMapSource

Map specialized for Int keys

status: stable

  • since 0.10
Sourcetype +'a t
Sourceval empty : 'a t
Sourceval is_empty : _ t -> bool

Is the map empty?

  • since 2.3
Sourceval singleton : int -> 'a -> 'a t
Sourceval doubleton : int -> 'a -> int -> 'a -> 'a t
Sourceval mem : int -> _ t -> bool
Sourceval find : int -> 'a t -> 'a option
Sourceval find_exn : int -> 'a t -> 'a

Same as find but unsafe.

Sourceval add : int -> 'a -> 'a t -> 'a t
Sourceval remove : int -> 'a t -> 'a t
Sourceval equal : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal ~eq a b checks whether a and b have the same set of pairs (key, value), comparing values with eq.

  • since 0.13
Sourceval compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int

Total order between maps; the precise order is unspecified.

  • since 0.13
Sourceval update : int -> ('a option -> 'a option) -> 'a t -> 'a t
Sourceval filter : (int -> 'a -> bool) -> 'a t -> 'a t

Filter values using the given predicate

  • since 2.3
Sourceval filter_map : (int -> 'a -> 'b option) -> 'a t -> 'b t

Filter-map values using the given function

  • since 2.3
Sourceval cardinal : _ t -> int

Number of bindings in the map. Linear time.

Sourceval iter : (int -> 'a -> unit) -> 'a t -> unit
Sourceval fold : (int -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
Sourceval mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
  • since 0.17
Sourceval map : ('a -> 'b) -> 'a t -> 'b t
  • since 0.17
Sourceval choose : 'a t -> (int * 'a) option
Sourceval choose_exn : 'a t -> int * 'a
Sourceval union : (int -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
Sourceval inter : (int -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
Sourceval merge : f:(int -> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] -> 'c option) -> 'a t -> 'b t -> 'c t

merge ~f m1 m2 merges m1 and m2 together, calling f once on every key that occurs in at least one of m1 and m2. if f k binding = Some c then k -> c is part of the result, else k is not part of the result.

  • since 2.3

Whole-collection operations

Sourcetype 'a sequence = ('a -> unit) -> unit
Sourcetype 'a gen = unit -> 'a option
Sourcetype 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
Sourceval add_list : 'a t -> (int * 'a) list -> 'a t
Sourceval of_list : (int * 'a) list -> 'a t
Sourceval to_list : 'a t -> (int * 'a) list
Sourceval add_seq : 'a t -> (int * 'a) sequence -> 'a t
Sourceval of_seq : (int * 'a) sequence -> 'a t
Sourceval to_seq : 'a t -> (int * 'a) sequence
Sourceval keys : _ t -> int sequence
Sourceval values : 'a t -> 'a sequence
Sourceval add_gen : 'a t -> (int * 'a) gen -> 'a t
  • since 0.13
Sourceval of_gen : (int * 'a) gen -> 'a t
  • since 0.13
Sourceval to_gen : 'a t -> (int * 'a) gen
  • since 0.13
Sourceval add_klist : 'a t -> (int * 'a) klist -> 'a t
  • since 0.13
Sourceval of_klist : (int * 'a) klist -> 'a t
  • since 0.13
Sourceval to_klist : 'a t -> (int * 'a) klist
  • since 0.13
Sourcetype 'a tree = unit -> [ `Nil | `Node of 'a * 'a tree list ]
Sourceval as_tree : 'a t -> [ `Node of int * int | `Leaf of int * 'a ] tree

IO

Sourcetype 'a printer = Format.formatter -> 'a -> unit
Sourceval pp : 'a printer -> 'a t printer
  • since 0.13

Helpers

OCaml

Innovation. Community. Security.