package batteries

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

Capabilities for hashtables.

@documents Hashtbl.Cap

type ('a, 'b, 'c) t constraint 'c = [< `Read | `Write ]

The type of a hashtable.

Constructors
val create : int -> ('a, 'b, _) t
val of_table : ('a, 'b) Hashtbl.t -> ('a, 'b, _) t

Adopt a regular hashtable as a capability hashtble, allowing to decrease capabilities if necessary.

This operation involves no copying. In other words, in let cap = of_table a in ..., any modification in a will also have effect on cap and reciprocally.

val to_table : ('a, 'b, [ `Read | `Write ]) t -> ('a, 'b) Hashtbl.t

Return a capability hashtable as a regular hashtable.

This operation requires both read and write permissions on the capability table and involves no copying. In other words, in let a = of_table cap in ..., any modification in a will also have effect on cap and reciprocally.

val read_only : ('a, 'b, [> `Read ]) t -> ('a, 'b, [ `Read ]) t

Drop to read-only permissions.

This operation involves no copying.

val write_only : ('a, 'b, [> `Write ]) t -> ('a, 'b, [ `Write ]) t

Drop to write-only permissions.

This operation involves no copying.

Base operations
val length : ('a, 'b, _) t -> int
val is_empty : ('a, 'b, _) t -> bool
val add : ('a, 'b, [> `Write ]) t -> 'a -> 'b -> unit
val remove : ('a, 'b, [> `Write ]) t -> 'a -> unit
val remove_all : ('a, 'b, [> `Write ]) t -> 'a -> unit
val replace : ('a, 'b, [> `Write ]) t -> 'a -> 'b -> unit
val copy : ('a, 'b, [> `Read ]) t -> ('a, 'b, _) t
val clear : ('a, 'b, [> `Write ]) t -> unit
Searching
val find : ('a, 'b, [> `Read ]) t -> 'a -> 'b
val find_all : ('a, 'b, [> `Read ]) t -> 'a -> 'b list
val find_default : ('a, 'b, [> `Read ]) t -> 'a -> 'b -> 'b
val find_option : ('a, 'b, [> `Read ]) t -> 'a -> 'b option
val mem : ('a, 'b, [> `Read ]) t -> 'a -> bool
Traversing
val iter : ('a -> 'b -> unit) -> ('a, 'b, [> `Read ]) t -> unit
val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b, [> `Read ]) t -> 'c -> 'c
val map : ('a -> 'b -> 'c) -> ('a, 'b, [> `Read ]) t -> ('a, 'c, _) t
val map_inplace : ('a -> 'b -> 'b) -> ('a, 'b, [> `Write ]) t -> unit
val filter : ('a -> bool) -> ('key, 'a, [> `Read ]) t -> ('key, 'a, _) t
val filter_inplace : ('a -> bool) -> ('key, 'a, [> `Write ]) t -> unit
val filteri : ('key -> 'a -> bool) -> ('key, 'a, [> `Read ]) t -> ('key, 'a, _) t
val filteri_inplace : ('key -> 'a -> bool) -> ('key, 'a, [> `Write ]) t -> unit
val filter_map : ('key -> 'a -> 'b option) -> ('key, 'a, [> `Read ]) t -> ('key, 'b, _) t
val filter_map_inplace : ('key -> 'a -> 'a option) -> ('key, 'a, [> `Write ]) t -> unit
val merge : ('key -> 'a option -> 'b option -> 'c option) -> ('key, 'a, [> `Read ]) t -> ('key, 'b, [> `Read ]) t -> ('key, 'c, _) t
val merge_all : ('key -> 'a list -> 'b list -> 'c list) -> ('key, 'a, [> `Read ]) t -> ('key, 'b, [> `Read ]) t -> ('key, 'c, _) t
Conversions
val keys : ('a, 'b, [> `Read ]) t -> 'a BatEnum.t
val values : ('a, 'b, [> `Read ]) t -> 'b BatEnum.t
val enum : ('a, 'b, [> `Read ]) t -> ('a * 'b) BatEnum.t
val of_enum : ('a * 'b) BatEnum.t -> ('a, 'b, _) t
val to_list : ('a, 'b, [> `Read ]) t -> ('a * 'b) list
val of_list : ('a * 'b) list -> ('a, 'b, _) t
Boilerplate code
Printing
val print : ?first:string -> ?last:string -> ?sep:string -> ?kvsep:string -> ('a BatInnerIO.output -> 'b -> unit) -> ('a BatInnerIO.output -> 'c -> unit) -> 'a BatInnerIO.output -> ('b, 'c, [> `Read ]) t -> unit
Override modules
module Exceptionless : sig ... end

Operations on BatHashtbl.Cap without exceptions.

module Labels : sig ... end

Operations on BatHashtbl.Cap with labels.

OCaml

Innovation. Community. Security.