Blame src/extHashtbl.mli

rpm-build 0f2925
(* 
rpm-build 0f2925
 * ExtHashtbl - extra functions over hashtables.
rpm-build 0f2925
 * Copyright (C) 2003 Nicolas Cannasse
rpm-build 0f2925
 * 
rpm-build 0f2925
 * This library is free software; you can redistribute it and/or
rpm-build 0f2925
 * modify it under the terms of the GNU Lesser General Public
rpm-build 0f2925
 * License as published by the Free Software Foundation; either
rpm-build 0f2925
 * version 2.1 of the License, or (at your option) any later version,
rpm-build 0f2925
 * with the special exception on linking described in file LICENSE.
rpm-build 0f2925
 *
rpm-build 0f2925
 * This library is distributed in the hope that it will be useful,
rpm-build 0f2925
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 0f2925
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 0f2925
 * Lesser General Public License for more details.
rpm-build 0f2925
 *
rpm-build 0f2925
 * You should have received a copy of the GNU Lesser General Public
rpm-build 0f2925
 * License along with this library; if not, write to the Free Software
rpm-build 0f2925
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
rpm-build 0f2925
 *)
rpm-build 0f2925
 
rpm-build 0f2925
(** Extra functions over hashtables. *)
rpm-build 0f2925
rpm-build 0f2925
module Hashtbl :
rpm-build 0f2925
  (** The wrapper module *)
rpm-build 0f2925
  sig
rpm-build 0f2925
rpm-build 0f2925
  type ('a,'b) t = ('a,'b) Hashtbl.t
rpm-build 0f2925
  (** The type of a hashtable. *)
rpm-build 0f2925
rpm-build 0f2925
  (** {6 New Functions} *)
rpm-build 0f2925
rpm-build 0f2925
  val exists : ('a,'b) t -> 'a -> bool
rpm-build 0f2925
  (** [exists h k] returns true is at least one item with key [k] is
rpm-build 0f2925
    found in the hashtable. *)
rpm-build 0f2925
rpm-build 0f2925
  val keys : ('a,'b) t -> 'a Enum.t
rpm-build 0f2925
  (** Return an enumeration of all the keys of a hashtable.
rpm-build 0f2925
      If the key is in the Hashtable multiple times, all occurrences
rpm-build 0f2925
      will be returned.  *)
rpm-build 0f2925
rpm-build 0f2925
  val values : ('a,'b) t -> 'b Enum.t
rpm-build 0f2925
  (** Return an enumeration of all the values of a hashtable. *)
rpm-build 0f2925
rpm-build 0f2925
  val enum : ('a, 'b) t -> ('a * 'b) Enum.t
rpm-build 0f2925
  (** Return an enumeration of (key,value) pairs of a hashtable. *)
rpm-build 0f2925
rpm-build 0f2925
  val of_enum : ('a * 'b) Enum.t -> ('a, 'b) t
rpm-build 0f2925
  (** Create a hashtable from a (key,value) enumeration. *)
rpm-build 0f2925
rpm-build 0f2925
  val find_default : ('a,'b) t -> 'a -> 'b -> 'b
rpm-build 0f2925
    (** Find a binding for the key, and return a default
rpm-build 0f2925
      value if not found *)
rpm-build 0f2925
rpm-build 0f2925
  val find_opt : ('a,'b) Hashtbl.t -> 'a -> 'b option
rpm-build 0f2925
  (** Find a binding for the key, or return [None] if no
rpm-build 0f2925
    value is found *)
rpm-build 0f2925
rpm-build 0f2925
  val find_option : ('a,'b) Hashtbl.t -> 'a -> 'b option
rpm-build 0f2925
  (** compatibility, use [find_opt] *)
rpm-build 0f2925
rpm-build 0f2925
  val remove_all : ('a,'b) t -> 'a -> unit
rpm-build 0f2925
  (** Remove all bindings for the given key *)
rpm-build 0f2925
rpm-build 0f2925
  val map : ('b -> 'c) -> ('a,'b) t -> ('a,'c) t
rpm-build 0f2925
  (** [map f x] creates a new hashtable with the same
rpm-build 0f2925
      keys as [x], but with the function [f] applied to
rpm-build 0f2925
    all the values *)
rpm-build 0f2925
rpm-build 0f2925
  val length : ('a,'b) t -> int
rpm-build 0f2925
  (** Return the number of elements inserted into the Hashtbl 
rpm-build 0f2925
    (including duplicates) *)
rpm-build 0f2925
rpm-build 0f2925
#if OCAML >= 400
rpm-build 0f2925
  val reset : ('a,'b) t -> unit
rpm-build 0f2925
  val randomize : unit -> unit
rpm-build 0f2925
rpm-build 0f2925
  type statistics = Hashtbl.statistics = {
rpm-build 0f2925
    num_bindings: int;
rpm-build 0f2925
    num_buckets: int;
rpm-build 0f2925
    max_bucket_length: int;
rpm-build 0f2925
    bucket_histogram: int array;
rpm-build 0f2925
  }
rpm-build 0f2925
rpm-build 0f2925
  val stats : ('a,'b) t -> statistics
rpm-build 0f2925
rpm-build 0f2925
  val seeded_hash_param : int -> int -> int -> 'a -> int
rpm-build 0f2925
  val seeded_hash : int -> 'a -> int
rpm-build 0f2925
#endif
rpm-build 0f2925
rpm-build 0f2925
#if OCAML >= 403
rpm-build 0f2925
  val is_randomized : unit -> bool
rpm-build 0f2925
  val filter_map_inplace : ('a -> 'b -> 'b option) -> ('a, 'b) t -> unit
rpm-build 0f2925
#endif
rpm-build 0f2925
rpm-build 0f2925
  (** {6 Older Functions} *)
rpm-build 0f2925
rpm-build 0f2925
  (** Please refer to the Ocaml Manual for documentation of these
rpm-build 0f2925
    functions. *)
rpm-build 0f2925
rpm-build 0f2925
  (** @before 4.00.0 [random] is ignored *)
rpm-build 0f2925
  val create : ?random:bool -> int -> ('a, 'b) t
rpm-build 0f2925
  val clear : ('a, 'b) t -> unit
rpm-build 0f2925
  val add : ('a, 'b) t -> 'a -> 'b -> unit
rpm-build 0f2925
  val copy : ('a, 'b) t -> ('a, 'b) t
rpm-build 0f2925
  val find : ('a, 'b) t -> 'a -> 'b
rpm-build 0f2925
  val find_all : ('a, 'b) t -> 'a -> 'b list
rpm-build 0f2925
  val mem : ('a, 'b) t -> 'a -> bool
rpm-build 0f2925
  val remove : ('a, 'b) t -> 'a -> unit
rpm-build 0f2925
  val replace : ('a, 'b) t -> 'a -> 'b -> unit
rpm-build 0f2925
  val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit
rpm-build 0f2925
  val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c
rpm-build 0f2925
  val hash : 'a -> int
rpm-build 0f2925
  val hash_param : int -> int -> 'a -> int
rpm-build 0f2925
rpm-build 0f2925
#if OCAML >= 407
rpm-build 0f2925
  (** [*_seq] functions were introduced in OCaml 4.07.0, and are _not_ implemented in extlib for older OCaml versions *)
rpm-build 0f2925
  val to_seq : ('a,'b) t -> ('a * 'b) Seq.t
rpm-build 0f2925
  val to_seq_keys : ('a,_) t -> 'a Seq.t
rpm-build 0f2925
  val to_seq_values : (_,'b) t -> 'b Seq.t
rpm-build 0f2925
  val add_seq : ('a,'b) t -> ('a * 'b) Seq.t -> unit
rpm-build 0f2925
  val replace_seq : ('a,'b) t -> ('a * 'b) Seq.t -> unit
rpm-build 0f2925
  val of_seq : ('a * 'b) Seq.t -> ('a, 'b) t
rpm-build 0f2925
#endif
rpm-build 0f2925
rpm-build 0f2925
(** Functor interface forwards directly to stdlib implementation (i.e. no enum functions) *)
rpm-build 0f2925
rpm-build 0f2925
#if OCAML >= 407
rpm-build 0f2925
rpm-build 0f2925
module type HashedType = Hashtbl.HashedType
rpm-build 0f2925
module type S = Hashtbl.S
rpm-build 0f2925
module Make = Hashtbl.Make
rpm-build 0f2925
rpm-build 0f2925
module type SeededHashedType = Hashtbl.SeededHashedType
rpm-build 0f2925
module type SeededS = Hashtbl.SeededS
rpm-build 0f2925
module MakeSeeded = Hashtbl.MakeSeeded
rpm-build 0f2925
rpm-build 0f2925
#else
rpm-build 0f2925
rpm-build 0f2925
module type HashedType =
rpm-build 0f2925
  sig
rpm-build 0f2925
    type t
rpm-build 0f2925
    val equal : t -> t -> bool
rpm-build 0f2925
    val hash : t -> int
rpm-build 0f2925
   end
rpm-build 0f2925
rpm-build 0f2925
module type S =
rpm-build 0f2925
  sig
rpm-build 0f2925
    type key
rpm-build 0f2925
    type 'a t
rpm-build 0f2925
    val create : int -> 'a t
rpm-build 0f2925
    val clear : 'a t -> unit
rpm-build 0f2925
#if OCAML >= 400
rpm-build 0f2925
    val reset : 'a t -> unit
rpm-build 0f2925
#endif
rpm-build 0f2925
    val copy : 'a t -> 'a t
rpm-build 0f2925
    val add : 'a t -> key -> 'a -> unit
rpm-build 0f2925
    val remove : 'a t -> key -> unit
rpm-build 0f2925
    val find : 'a t -> key -> 'a
rpm-build 0f2925
#if OCAML >= 405
rpm-build 0f2925
    val find_opt : 'a t -> key -> 'a option
rpm-build 0f2925
#endif
rpm-build 0f2925
    val find_all : 'a t -> key -> 'a list
rpm-build 0f2925
    val replace : 'a t -> key -> 'a -> unit
rpm-build 0f2925
    val mem : 'a t -> key -> bool
rpm-build 0f2925
    val iter : (key -> 'a -> unit) -> 'a t -> unit
rpm-build 0f2925
#if OCAML >= 403
rpm-build 0f2925
    val filter_map_inplace: (key -> 'a -> 'a option) -> 'a t -> unit
rpm-build 0f2925
#endif
rpm-build 0f2925
    val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
rpm-build 0f2925
    val length : 'a t -> int
rpm-build 0f2925
#if OCAML >= 400
rpm-build 0f2925
    val stats: 'a t -> statistics
rpm-build 0f2925
#endif
rpm-build 0f2925
  end
rpm-build 0f2925
rpm-build 0f2925
module Make (H : HashedType) : S with type key = H.t
rpm-build 0f2925
rpm-build 0f2925
#if OCAML >= 400
rpm-build 0f2925
module type SeededHashedType =
rpm-build 0f2925
  sig
rpm-build 0f2925
    type t
rpm-build 0f2925
    val equal: t -> t -> bool
rpm-build 0f2925
    val hash: int -> t -> int
rpm-build 0f2925
  end
rpm-build 0f2925
rpm-build 0f2925
module type SeededS =
rpm-build 0f2925
  sig
rpm-build 0f2925
    type key
rpm-build 0f2925
    type 'a t
rpm-build 0f2925
    val create : ?random:bool -> int -> 'a t
rpm-build 0f2925
    val clear : 'a t -> unit
rpm-build 0f2925
    val reset : 'a t -> unit
rpm-build 0f2925
    val copy : 'a t -> 'a t
rpm-build 0f2925
    val add : 'a t -> key -> 'a -> unit
rpm-build 0f2925
    val remove : 'a t -> key -> unit
rpm-build 0f2925
    val find : 'a t -> key -> 'a
rpm-build 0f2925
#if OCAML >= 405
rpm-build 0f2925
    val find_opt : 'a t -> key -> 'a option
rpm-build 0f2925
#endif
rpm-build 0f2925
    val find_all : 'a t -> key -> 'a list
rpm-build 0f2925
    val replace : 'a t -> key -> 'a -> unit
rpm-build 0f2925
    val mem : 'a t -> key -> bool
rpm-build 0f2925
    val iter : (key -> 'a -> unit) -> 'a t -> unit
rpm-build 0f2925
#if OCAML >= 403
rpm-build 0f2925
    val filter_map_inplace: (key -> 'a -> 'a option) -> 'a t -> unit
rpm-build 0f2925
#endif
rpm-build 0f2925
    val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
rpm-build 0f2925
    val length : 'a t -> int
rpm-build 0f2925
    val stats: 'a t -> statistics
rpm-build 0f2925
  end
rpm-build 0f2925
rpm-build 0f2925
module MakeSeeded (H : SeededHashedType) : SeededS with type key = H.t
rpm-build 0f2925
#endif
rpm-build 0f2925
rpm-build 0f2925
#endif
rpm-build 0f2925
rpm-build 0f2925
  end