Version française
Home     About     Download     Resources     Contact us    
Browse thread
problem with Hashtbl.add function...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: RICCI Pierre <pricci@c...>
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
____________________________________________________________
************************************************************