Re: [Mono-dev] faster than hashtable?

2009-10-29 Thread Konstantin Triger
You may also consider using bit dictionary algorythms: Suppose your key is n bits long, you divide it to k levels each m bits (k*m = n). At each level you have 2^m arrays that point to the next level array etc, while at last it will be an array of values. Provided the range of potential keys is

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Tom Spink
2009/10/27 psant...@codicesoftware.com psant...@codicesoftware.com: Hi, If you need to store key/value pairs, where the key will be ALWAYS a unique long (no collisions), is there anything better than a Hashtable? Thanks        pablo Presumably, though, the key can span the entire range of

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Alan McGovern
If the key is random, a hashtable is the fastest way. You may be able to eke some extra speed out of the DictionaryK, V class by ripping all the code to support generic keys and instead hardcode the key to always be a long. That should save a bit of time, though whether it'd be noticable or not I

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Oskar Berggren
If you know your input set and can design a hash function that is guaranteed to never give collisions for that input set, you could perhaps gain something by implementing a hash table that ignores the risk of collisions. /Oskar 2009/10/28 Alan McGovern alan.mcgov...@gmail.com: If the key is

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread pablosantosl...@terra.es
Thanks, Good to know! I'll give it a try. Alan McGovern wrote: If the key is random, a hashtable is the fastest way. You may be able to eke some extra speed out of the DictionaryK, V class by ripping all the code to support generic keys and instead hardcode the key to always be a long. That

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Felipe Lessa
On Tue, Oct 27, 2009 at 11:58:31PM +0100, psant...@codicesoftware.com wrote: If you need to store key/value pairs, where the key will be ALWAYS a unique long (no collisions), is there anything better than a Hashtable? There are always Judy arrays, see http://judy.sourceforge.net/. -- Felipe.

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread pablosantosl...@terra.es
Excellent. Is there a wrapper for C#? Is it worth? Felipe Lessa wrote: On Tue, Oct 27, 2009 at 11:58:31PM +0100, psant...@codicesoftware.com wrote: If you need to store key/value pairs, where the key will be ALWAYS a unique long (no collisions), is there anything better than a Hashtable?

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Alan McGovern
Really what you need to do is benchmark all of the different options using your expected workload. It's near useless us telling you X is faster or Y is better without knowing the workload involved. Alan. On Wed, Oct 28, 2009 at 2:40 PM, pablosantosl...@terra.es pablosantosl...@terra.es wrote:

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Felipe Lessa
On Wed, Oct 28, 2009 at 12:40 PM, pablosantosl...@terra.es pablosantosl...@terra.es wrote: Excellent. Is there a wrapper for C#? Is it worth? Not that I know of, however it shouldn't be hard to create one. -- Felipe. ___ Mono-devel-list mailing list

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread pablosantosl...@terra.es
Sure Alan! So, basically, the options are: - Use a sorted ArrayList and a binary search - Reimplement hashtable focusing on long keys - Write a wrapper to Judy Alan McGovern wrote: Really what you need to do is benchmark all of the different options using your expected workload. It's near

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Alan McGovern
Hey, On Wed, Oct 28, 2009 at 4:30 PM, pablosantosl...@terra.es pablosantosl...@terra.es wrote: Sure Alan! So, basically, the options are: - Use a sorted ArrayList and a binary search For this option the same story applies as for Dictionary K,V. If you write a strongly typed sorted list

Re: [Mono-dev] faster than hashtable?

2009-10-28 Thread Rafael Teixeira
As p/invokes cost a lot, another (fourth) option would be to reimplement judy arrays algorithm (which I admittedly know nearly nothing about) in managed code. From reading their 10 minutes intro, I guess some of the cache-fill optimizations it implements may be jeopardized by the JIT workings, but

[Mono-dev] faster than hashtable?

2009-10-27 Thread psant...@codicesoftware.com
Hi, If you need to store key/value pairs, where the key will be ALWAYS a unique long (no collisions), is there anything better than a Hashtable? Thanks pablo ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com