A quick way to map unordered list of longs to buffer location ?

Posted by alhazen on Stack Overflow See other posts from Stack Overflow or by alhazen
Published on 2011-01-11T16:49:41Z Indexed on 2011/01/11 16:54 UTC
Read the original article Hit count: 184

Filed under:
|
|
|
|

I have a large number of points (indexed by long) that are processed by multiple threads and I'm using a buffer to hold the output results in order. As the number of points processed is huge, what would be an efficient way to map the indexes of the points to the corresponding ordered position in the buffer ?

Example:

long           bufferIndex         bufferIndex     
index     (if BufferSize = 2)    (if BufferSize = 4)
----------------------------------------------
2938               0                   0
2939               1                   1
2941               1                   3
2940               0                   2

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET