News for hackers. Stuff that matters.
Re:Maps are Broken, for Some Definition of Broken by billnapier on Tuesday June 22, 2010 @01:54PM (#1452600)
HashMap (unlike treeset) itself doesn't provide an order guarantee. So can't you just grab the first element from the entrySet and use that?

But I think the bigger problem is trying to use a Map in the first place when maybe a different data structure will solve the problem better.

Re:Maps are Broken, for Some Definition of Broken by apgwoz on Tuesday June 22, 2010 @02:07PM (#1452639)
I of course didn't talk about why I'm using a map, but as an example: consider redis. It's a giant hash table, and it allows you to pick a random key.
Re:Maps are Broken, for Some Definition of Broken by nervechannel on Wednesday June 23, 2010 @03:57AM (#1454388)
Just because it doesn't make any guarantees about order, doesn't mean you'll get a randomly-selected element if you pick the first one.