BatHashtbl.Cap

# Module BatHashtbl.Cap

    module Cap: sig .. end

Capabilities for hashtables.

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

The type of a hashtable.

###### Constructors

    val create : int -> ('a, 'b, [< `Read | `Write ]) t

    val of_table : ('a, 'b) Hashtbl.t -> ('a, 'b, [< `Read | `Write ]) 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 | `Write > `Read ]) t ->
           ('a, 'b, [ `Read ]) t

Drop to read-only permissions.

This operation involves no copying.

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

Drop to write-only permissions.

This operation involves no copying.

    val length : ('a, 'b, [< `Read | `Write ]) t -> int

###### Base operations

    val is_empty : ('a, 'b, [< `Read | `Write ]) t -> bool

    val add : ('a, 'b, [< `Read | `Write > `Write ]) t -> 'a -> 'b -> unit

    val remove : ('a, 'b, [< `Read | `Write > `Write ]) t -> 'a -> unit

    val remove_all : ('a, 'b, [< `Read | `Write > `Write ]) t -> 'a -> unit

    val replace : ('a, 'b, [< `Read | `Write > `Write ]) t -> 'a -> 'b -> unit

    val copy : ('a, 'b, [< `Read | `Write > `Read ]) t ->
           ('a, 'b, [< `Read | `Write ]) t

    val clear : ('a, 'b, [< `Read | `Write > `Write ]) t -> unit

###### Searching

    val find : ('a, 'b, [< `Read | `Write > `Read ]) t -> 'a -> 'b

    val find_all : ('a, 'b, [< `Read | `Write > `Read ]) t -> 'a -> 'b list

    val find_default : ('a, 'b, [< `Read | `Write > `Read ]) t -> 'a -> 'b -> 'b

    val find_option : ('a, 'b, [< `Read | `Write > `Read ]) t -> 'a -> 'b option

    val mem : ('a, 'b, [< `Read | `Write > `Read ]) t -> 'a -> bool

`exists h k` returns true is at least one item with key `k` is found in the hashtable.

    val iter : ('a -> 'b -> unit) ->
           ('a, 'b, [< `Read | `Write > `Read ]) t -> unit

###### Traversing

    val fold : ('a -> 'b -> 'c -> 'c) ->
           ('a, 'b, [< `Read | `Write > `Read ]) t -> 'c -> 'c

    val map : ('a -> 'b -> 'c) ->
           ('a, 'b, [< `Read | `Write > `Read ]) t ->
           ('a, 'c, [< `Read | `Write ]) t

    val filter : ('a -> bool) ->
           ('b, 'a, [< `Read | `Write > `Read ]) t ->
           ('b, 'a, [< `Read | `Write ]) t

    val filteri : ('a -> 'b -> bool) ->
           ('a, 'b, [< `Read | `Write > `Read ]) t ->
           ('a, 'b, [< `Read | `Write ]) t

    val filter_map : ('a -> 'b -> 'c option) ->
           ('a, 'b, [< `Read | `Write > `Read ]) t ->
           ('a, 'c, [< `Read | `Write ]) t

###### Conversions

    val keys : ('a, 'b, [< `Read | `Write > `Read ]) t -> 'a BatEnum.t

    val values : ('a, 'b, [< `Read | `Write > `Read ]) t -> 'b BatEnum.t

    val enum : ('a, 'b, [< `Read | `Write > `Read ]) t -> ('a * 'b) BatEnum.t

    val of_enum : ('a * 'b) BatEnum.t -> ('a, 'b, [< `Read | `Write ]) t

###### Boilerplate code

Printing

    val print : ?first:string ->
           ?last:string ->
           ?sep:string ->
           ('a BatInnerIO.output -> 'b -> unit) ->
           ('a BatInnerIO.output -> 'c -> unit) ->
           'a BatInnerIO.output ->
           ('b, 'c, [< `Read | `Write > `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.