[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...> |
| Subject: | Re: newbie question (map/hashtbl size) |
In his message of Sat February 10, 2001, Ronaldo Carpio writes:
>
> How do you get the size of a hashtable or map?
An esay solution is to use a reference and the iteration function
provided with the datatype, like this:
======================================================================
# let hashtbl_size h =
let n = ref 0 in Hashtbl.iter (fun _ _ -> incr n) h; !n;;
val hashtbl_size : ('a, 'b) Hashtbl.t -> int = <fun>
======================================================================
Hope this helps,
--
Jean-Christophe FILLIATRE
mailto:Jean-Christophe.Filliatre@lri.fr
http://www.lri.fr/~filliatr