двухсторонняя таблица поиска, C #

Мне нужно принять проектное решение по некоторой структуре данных для чрезвычайно быстрого доступа. Вот сценарий: I have to sync two variables of different growth rate. I have tabulated data of in the following format:

Range( Ai1, Ai2) ~ Range ( Bi1, Bi2) That is to say that the range Ai1 - Ai2 matches Bi1 - Bi2 for some i

Now given any Ax in the entire span of A I should be able to determine the appropriate range in (Bj1, Bj2) and vice-versa. Data type wise : A is int; while B is float.

I don't know what would be the most appropriate data type for this translation ? My primary requirement is speed. Also any help in how this data struct can be implemented in C# would be helpful.

The problem is assured to fit in memory. Span of A can be approx the range 0 - 300,000, and the size of range Ai1-Ai2 can be some where from 10 to 300 ; while the span of span of the float is 0 to 10,000.000 ( we use only 3 decimal places) and the size of range Bi1 - Bi2 can be something like 0.100 - 10.000

Another known fact is that A is assured to be continuous while B may not be. But both increase sort of simultaneously, but at varying rates.Also neither Ranges overlap. Both are monotonically increasing.

So something like this can be expected:

(Ai1, Ai2) ~ ( Bi1, Bi2)

(1,78) ~ (13.454, 19.546)

(79,114) ~ (19.712,22.335)

(115, 198) ~ ( 22.678, 24.101)

query: A = 99 , Expected Response: B range = (19.712,22.335)

query: B = 16.117 , Expected Response: A range= (1,78)

In case B is not in range forward roundoff is expected.

Thnx-Egon

6
задан Egon 9 March 2011 в 17:08
поделиться