Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
Can somone tell me why they would choose to implement the Hashtable in such a way?
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
Originally posted by Henry Wong:
I believe the .NET Hashtable throws an exception if the element (with the same key) already exists. So technically, you can say this is done in C#, J#, Managed C++, and Visual Basic...
Originally posted by Rob Mech:
from a database perspective youre never allowed to insert a duplicate key into any index either.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
"I'm not back." - Bill Harding, Twister
Originally posted by Peter Chase:
OK, but this isn't a relational database, it's a low-level in-memory data structure. There's no reason why Java hash maps should behave like relational database indexes, because they're not the same thing.
There is a valid debate to be had about whether maps should allow replacement of existing entries - some applications will find it useful, others a pain. But I don't really see how the behaviour of relational databases informs that debate.
Are you coming to Java from an SQL background, by any chance?
Originally posted by Jim Yingst:
Thinking about this, I can see where throwing an exception would be useful sometimes, though not always. But silently ignoring a new put()? That seems far more likely to induce bugs, to me. But maybe that's just because I'm used to put() behaving the way it does.
Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|