B
bahoo
Hi,
My data is organized like this, where A always goes from 1 to some
number N:
A 1 2 3 ...
B 53,26 42,18 15,86 ...
C 59 43 31 ...
I often need to look up in this way:
Given B=18, what is the corresponding value of A and C? (Answer is 2
and 43).
My current implementation is a for-loop that goes through all A's and
checks if the B value is the query, and if yes, return the
corresponding A and C. But this is very inefficient.
Could anyone please suggest me a better data structure for doing this,
better be a built-in one?
Observe that B always appears in pairs, and when I look up, I may use
either value within the pair.
Thanks!
bahoo
My data is organized like this, where A always goes from 1 to some
number N:
A 1 2 3 ...
B 53,26 42,18 15,86 ...
C 59 43 31 ...
I often need to look up in this way:
Given B=18, what is the corresponding value of A and C? (Answer is 2
and 43).
My current implementation is a for-loop that goes through all A's and
checks if the B value is the query, and if yes, return the
corresponding A and C. But this is very inefficient.
Could anyone please suggest me a better data structure for doing this,
better be a built-in one?
Observe that B always appears in pairs, and when I look up, I may use
either value within the pair.
Thanks!
bahoo