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] Is System.Drawing (libgdiplus) thread-safe?

2009-10-28 Thread Alex Shulgin
Hi all, Is System.Drawing by any means thread-safe? Can I create some threads, create a Graphics object in each of them and then work with it from within that thread? Is this supposed to work or am I doing something really stupid here? I ask because I've noticed random crashes in a

Re: [Mono-dev] [Mono-winforms-list] Is System.Drawing (libgdiplus) thread-safe?

2009-10-28 Thread Alex Shulgin
Alex Shulgin wrote: Hi all, Is System.Drawing by any means thread-safe? Can I create some threads, create a Graphics object in each of them and then work with it from within that thread? Is this supposed to work or am I doing something really stupid here? Oh, forgot to mention that

Re: [Mono-dev] [Mono-winforms-list] Is System.Drawing (libgdiplus) thread-safe?

2009-10-28 Thread Sebastien Pouliot
On Wed, 2009-10-28 at 19:37 +0200, Alex Shulgin wrote: Hi all, Is System.Drawing by any means thread-safe? No, like most of the .net framework, i.e. quoteAny public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not

Re: [Mono-dev] [Mono-winforms-list] Is System.Drawing (libgdiplus) thread-safe?

2009-10-28 Thread Sebastien Pouliot
On Wed, 2009-10-28 at 19:47 +0200, Alex Shulgin wrote: Alex Shulgin wrote: Hi all, Is System.Drawing by any means thread-safe? Can I create some threads, create a Graphics object in each of them and then work with it from within that thread? Is this supposed to work or am I

Re: [Mono-dev] Is System.Drawing (libgdiplus) thread-safe?

2009-10-28 Thread Miguel de Icaza
Hello, It is thread safe for instances of objects, but you can not mix objects that need to interact with the windowing system with calls made in separate threads. The simple solution is to make sure that anything that interacts with the GUI uses Control.Invoke. On Oct 28, 2009,