Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: RICCI Pierre <pricci@cenatoulouse.dgac.fr>
To: caml-list@inria.fr
Subject: problem with Hashtbl.add function...
Date: Fri, 26 Feb 1999 14:03:28 +0100	[thread overview]
Message-ID: <36D69BA0.883EDADD@cenatls.cena.dgac.fr> (raw)

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
____________________________________________________________
************************************************************






             reply	other threads:[~1999-02-26 19:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-26 13:03 RICCI Pierre [this message]
1999-03-02 10:35 ` Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36D69BA0.883EDADD@cenatls.cena.dgac.fr \
    --to=pricci@cenatoulouse.dgac.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox