Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Hash over ref
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jdh30@c...>
Subject: Re: [Caml-list] Hash over ref

Ok, thanks for all the advice from everyone. :-)

Essentially, I wish to hash the pointer value of the reference itself. So, if 
a reference were reassigned, then the hash would be different. Two identical 
copies of an object would have different references and, consequently, would 
give different hashes (i.e. a != b is true where a and b are 'a ref).

The reason I want to do this is to spot duplicate uses of a single object 
(multiple references to it) but without confusing this with different uses of 
identical objects (i.e. where "=" would give true but "==" would not).

I can think of a couple of alternative approaches. I could implement a naff 
kind of set as a list which used "==" to test for equality. Or, I could loop 
through all of the references to the objects, marking unmarked objects with a 
new identifier (an int, say) and then insert them all into a Hashtbl on the 
basis of their identifiers. I just thought hashing refs themselves would be 
simpler.

I think I can do this given Alain's code though, thanks!

Cheers,
Jon.

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