added length function.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6167 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
90f3ac484a
commit
2c8fe3ae6b
|
@ -44,6 +44,8 @@ let copy h =
|
||||||
{ size = h.size;
|
{ size = h.size;
|
||||||
data = Array.copy h.data }
|
data = Array.copy h.data }
|
||||||
|
|
||||||
|
let length h = h.size
|
||||||
|
|
||||||
let resize hashfun tbl =
|
let resize hashfun tbl =
|
||||||
let odata = tbl.data in
|
let odata = tbl.data in
|
||||||
let osize = Array.length odata in
|
let osize = Array.length odata in
|
||||||
|
@ -184,6 +186,7 @@ module type S =
|
||||||
val mem : 'a t -> key -> bool
|
val mem : 'a t -> key -> bool
|
||||||
val iter: (key -> 'a -> unit) -> 'a t -> unit
|
val iter: (key -> 'a -> unit) -> 'a t -> unit
|
||||||
val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
|
val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
|
||||||
|
val length: 'a t -> int
|
||||||
end
|
end
|
||||||
|
|
||||||
module Make(H: HashedType): (S with type key = H.t) =
|
module Make(H: HashedType): (S with type key = H.t) =
|
||||||
|
@ -272,4 +275,7 @@ module Make(H: HashedType): (S with type key = H.t) =
|
||||||
|
|
||||||
let iter = iter
|
let iter = iter
|
||||||
let fold = fold
|
let fold = fold
|
||||||
|
let length = length
|
||||||
end
|
end
|
||||||
|
|
||||||
|
(* eof $Id$ *)
|
||||||
|
|
|
@ -35,6 +35,7 @@ val create : int -> ('a, 'b) t
|
||||||
val clear : ('a, 'b) t -> unit
|
val clear : ('a, 'b) t -> unit
|
||||||
(** Empty a hash table. *)
|
(** Empty a hash table. *)
|
||||||
|
|
||||||
|
|
||||||
val add : ('a, 'b) t -> 'a -> 'b -> unit
|
val add : ('a, 'b) t -> 'a -> 'b -> unit
|
||||||
(** [Hashtbl.add tbl x y] adds a binding of [x] to [y] in table [tbl].
|
(** [Hashtbl.add tbl x y] adds a binding of [x] to [y] in table [tbl].
|
||||||
Previous bindings for [x] are not removed, but simply
|
Previous bindings for [x] are not removed, but simply
|
||||||
|
@ -91,6 +92,12 @@ val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c
|
||||||
the most recent binding is passed first. *)
|
the most recent binding is passed first. *)
|
||||||
|
|
||||||
|
|
||||||
|
val length : ('a, 'b) t -> int
|
||||||
|
(** [Hashtbl.length tbl] returns the number of bindings in [tbl].
|
||||||
|
Multiple bindings are counted multiply, so [Hashtbl.length]
|
||||||
|
gives the number of times [Hashtbl.iter] calls it first argument. *)
|
||||||
|
|
||||||
|
|
||||||
(** {6 Functorial interface} *)
|
(** {6 Functorial interface} *)
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,6 +137,7 @@ module type S =
|
||||||
val mem : 'a t -> key -> bool
|
val mem : 'a t -> key -> bool
|
||||||
val iter : (key -> 'a -> unit) -> 'a t -> unit
|
val iter : (key -> 'a -> unit) -> 'a t -> unit
|
||||||
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
|
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
|
||||||
|
val length : 'a t -> int
|
||||||
end
|
end
|
||||||
(** The output signature of the functor {!Hashtbl.Make}. *)
|
(** The output signature of the functor {!Hashtbl.Make}. *)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue