in reply to Re: What makes an array sorted and a hash unsorted?
in thread What makes an array sorted and a hash unsorted?
Hashes, on the other hand, are intrinsically not ordered internally. In fact, this feature is what allows for (relatively) inexpensive insertion and deletion. (Two items with keys very close to each other are likely to end up in different areas of the hash table.)That's not correct. Hash keys are ordered, otherwise you wouldn't be able to quickly search for them (and hence, no quick deletion either). However, the order internally isn't the same order people want (this thread seems to consider "ordered hashes" as "keys are sorted" - it's not uncommon for people to mean "keys returned in insertion order" when they talk about "ordered hashes"). I've always understood that keys (and its friends) return the keys in the way they are laid out internally - so certainly "ordered", but only after applying a hash function.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: What makes an array sorted and a hash unsorted?
by gwadej (Chaplain) on Jun 02, 2009 at 03:40 UTC | |
Re^3: What makes an array sorted and a hash unsorted?
by herveus (Prior) on Jun 02, 2009 at 12:32 UTC | |
by JavaFan (Canon) on Jun 02, 2009 at 15:03 UTC | |
by herveus (Prior) on Jun 03, 2009 at 13:31 UTC | |
by JavaFan (Canon) on Jun 03, 2009 at 15:18 UTC | |
by herveus (Prior) on Jun 03, 2009 at 18:33 UTC | |
| |
by JavaFan (Canon) on Jun 03, 2009 at 14:00 UTC | |
by herveus (Prior) on Jun 03, 2009 at 14:16 UTC |