problem with Hashtbl.add function...

From: RICCI Pierre (pricci@cenatoulouse.dgac.fr)
Date: Fri Feb 26 1999 - 14:03:28 MET


Message-Id: <36D69BA0.883EDADD@cenatls.cena.dgac.fr>
Date: Fri, 26 Feb 1999 14:03:28 +0100
From: RICCI Pierre <pricci@cenatoulouse.dgac.fr>
To: caml-list@inria.fr
Subject: problem with Hashtbl.add function...

Hi, I have a little problem with the function Hashtbl.add.
I use it in a form like this:
List.iter (fun a:->Hashtbl.add tbl !time a) !b;
where (b:aircraft) is a list of structure like
type aircraft = {
    pln : pln;
    mutable where : point3D;
    mutable heading : seconds;
    mutable cfl : level;
    mutable phase : phase;
    mutable g_speed : kts;
    mutable v_speed : feetpmn;
    mutable sector : string;
    mutable instruction : (action * int * int) option;
    err_gspeed : int; (* 100 +/- 5
*)
    err_vspeed : int (* 100 +/- 20
*)
  }
where pln, point3D... are structures too.

The result of the add command might give me a hashing table with a
key=time and data=aircrafts with their position for each key.
The problem is I obtain a hashing table where key=time but
data=aircrafts with always the same position for each one.

I think maybe it's the parameter "n" in (Hashtbl.hash_param n m x) which
is too small, but I dont know how to change it. If, I want to rewrite
the add function in my program, using n parameter with 30 by example,
the compilator tells me he doesn't know the data field of h.

let add h key info =
  let i = (hash_param 10 100 key) mod (Array.length h.data) in
  let bucket = Cons(key, info, h.data.(i)) in
  h.data.(i) <- bucket;
  if bucket_too_long h.max_len bucket then resize hash h

Can anyone help me ?

PS: Please escuse me if the error is too simple but I don't see the
mistake.
bye.

--
____________________________________________________________

Pierre RICCI | Email : pricci@cenatls.cena.dgac.fr | Tel : (+33) 62 25 95 28 CENA Toulouse | Fax : (+33) 62 25 95 99 ____________________________________________________________

Cellule MSS ( Modelisation Stochastique et Statistiques ) ____________________________________________________________

7 avenue Edouard Belin BP 4005 (site de l'ENAC) 31055 Toulouse Cedex FRANCE ____________________________________________________________ ************************************************************



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:20 MET