Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Are ordered hashes useful?
- Date: Wed, 16 Feb 2011 08:13:18 +0100
- From: Josh Glover <jmglov@example.com>
- Subject: Re: [tlug] Are ordered hashes useful?
- References: <4D4E75AB.5060703@example.com> <4D4FB368.4010403@example.com> <AANLkTimk8AUJMRiwbPjGfDfciCwfaQr9_o3vBXtW2+rW@example.com> <87lj1rza76.fsf@example.com> <AANLkTikqy8G6G1Pt3ramSqxKHKJHSpo=zjHYLVENW0Gb@example.com> <878vxqyfok.fsf@example.com> <AANLkTiknPv3VsKzKQVxMacFE9i9aSSmwXDU4Fz+rZU3g@example.com> <AANLkTi=-0DXwOzc4yOriXptsvXkNZGh71Jgm=Rzu_2tW@example.com> <87y65iqchr.fsf@example.com> <4D59EC1B.9040403@example.com> <AANLkTinGHv=QWz++VYMLAWHZsLt1vUm0Nd5u_n2Jsaj_@example.com>
On 15 February 2011 17:47, Marty Pauley <marty.pauley@example.com> wrote: > Hashes don't cope well with a large amount of data (unless it's known > in advance). Just for the benefit of the list: A "hash" (associative array / dictionary) is usually implemented as an array of b number of buckets, with each bucket corresponding to one output of the hashing function. Each bucket typically contains a linked list of length l, where l is the number of objects inserted that hashed to the same output value. As you insert more and more data, you get more collisions and thus longer lists in each bucket. Though lookup time is still constant time--O(1)--the actual time taken does increase, because traversing a linked list is O(n). So if you have 1 million values in your hash table in bucket 3, it is going to take you a million and one operations to fetch an object if you are so unlucky as to need the last one in bucket 3. There are more sophisticated implementations I'm sure, but that is how it works in theory. Some hash implementations let you specify an expected data size when constructing a new hash, which is what Marty was alluding to there at the end. Cheers, Josh
- Follow-Ups:
- Re: [tlug] Are ordered hashes useful?
- From: Raymond Wan
- Re: [tlug] Are ordered hashes useful?
- From: Stephen J. Turnbull
- References:
- [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Dave M G
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Raymond Wan
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Josh Glover
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Stephen J. Turnbull
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Josh Glover
- [tlug] Are ordered hashes useful?
- From: Stephen J. Turnbull
- Re: [tlug] Are ordered hashes useful?
- From: Jun-Dai Bates-Kobashigawa
- Re: [tlug] Are ordered hashes useful?
- From: Marty Pauley
- Re: [tlug] Are ordered hashes useful?
- From: Stephen J. Turnbull
- Re: [tlug] Are ordered hashes useful?
- From: Raymond Wan
- Re: [tlug] Are ordered hashes useful?
- From: Marty Pauley
Home | Main Index | Thread Index
- Prev by Date: [tlug] Docomo N2502 card on Linux
- Next by Date: Re: [tlug] Are ordered hashes useful?
- Previous by thread: Re: [tlug] Are ordered hashes useful?
- Next by thread: Re: [tlug] Are ordered hashes useful?
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links