Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Using references as hash keys

by tye (Sage)
on Oct 16, 2005 at 04:09 UTC ( #500532=note: print w/replies, xml ) Need Help??

in reply to Using references as hash keys

The whole concept of a hash is having a hashing function, a sort of check-sum. So an 'isEqual' function just doesn't enable making a hash.

You can emulate a hash using a tree if you provide an 'isLessThan' function. But you'd have to implement an ordered tree rather than just use Perl's hashes.

But just about any 'isEqual' function can be transformed into a 'getKey' function that returns a string such that isEqual($a,$b) iff getKey($a) eq getKey($b). And, you've surely realized, the result of getKey can be used as the key in a Perl hash.

- tye        

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://500532]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2023-01-29 05:21 GMT
Find Nodes?
    Voting Booth?

    No recent polls found