Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] sorting Hashtbl.t
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Yann_Régis-Gianas <yann@l...>
Subject: Re: [Caml-list] sorting Hashtbl.t
On Sun, Aug 11, 2002 at 09:08:24PM -0400, Oleg wrote:
> Hi

	Hi,

> Is there any way to sort Hashtlb.t or otherwise make Hashtbl.iter iterate 
> elements in order [1]?
> 

	From an algorithmic point of view, there is no way to sort an
hash table since there is no order attached to items. Indeed, the
association is done through hash function that gives a fast-computable
signature to each key to find them quickly. (Re-)read the Cormen's book
to understand why you can't ask for such a feature ...

	Maybe you want Map.t that is an ordered associative structure ?



-- 
Yann Régis-Gianas.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners