Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Using references as hash keys

by tye (Sage)
on Oct 16, 2005 at 04:09 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-28 18:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found