algorithm - Implementing a sparse array in C# / fastest way to map integer to a specific bucket/range number -
My initial problem is that I need to implement a fast, fast array in C #. The basic idea is a general dictionary & lt; Uint, tvalue & gt;
and it wrapped itself to expose only the TValue
type parameter in its own class, it is very slow.
So my next idea was to map each integer in the required category ( UInt32.MinValue
to UInt32.MaxValue
) for a bucket, some size Use that and so I am looking for a good way to map a signed integer x to a bucket of y, for example:
Numbers 0-1023 to 8 different bytes to 128 Number each, 0-127, 128 -255.
But if someone has a better way of implementing a sharp sparse array in C #, then it would also be appreciated.
I also saw that when the key is an integer, then dictionary & lt; K, V>
is slow I do not know why this is the case, but I have written a fast hash table implementation for the uint
and ulong
key:
-
64-bit A (the key
Ulong
) is normal, but the second (keyuint
) assumes the valueint
because that's all I need at that time; I'm sure you can do this easily. -
Currently Capacity sets the size of the hashtable always (i.e. does not grow)
Comments
Post a Comment