in reply to Re^2: What makes an array sorted and a hash unsorted?
in thread What makes an array sorted and a hash unsorted?
Hash keys have no predefined ordering. Any given call to keys() will present the keys as a list which will, at that instant, have an order, but that particular ordering is neither persistent nor stable nor predictable in the face of insertions and deletions. Rapid searching for hash keys has nothing to do with ordering, but rather with the nature of hash functions. Ideally, any given key value hashes to a unique value in the hash that can be found (or the existence of tested for) in constant time. Searching an ordered list is going to be O(log n) or worse.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: What makes an array sorted and a hash unsorted?
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 20:31 UTC | |
by JavaFan (Canon) on Jun 03, 2009 at 14:00 UTC | |
by herveus (Prior) on Jun 03, 2009 at 14:16 UTC |