Hi, I am so confused about how to build up a 3-dimension lookup table. Is the template as follows: create a 3 dimensional array to store data. Then create linked list. Then create function 'insert' to put all the data into the array? As some book said, linked list should be static const, is it need to create another function to expand the list? Because the lookup table should be used in a microcontroller, it only needs to finish the operation of putting the data into the array and whenever want to find the data, it will be fast and easy to search. Could you help me with that and give me some suggestions? Thank you.
A:
Suppose you have a table of 3x5x7 then you can store the table as a one dimensional array of 3*5*7 = 105 items
If you index the items like this
table[x+3*(y+5*z)]
the 105 items should be stored in the table in this order [x,y,z]
[0,0,0]
[1,0,0]
[2,0,0]
[0,1,0]
[1,1,0]
[2,1,0]
[0,2,0]
[1,2,0]
[2,2,0]
[0,3,0]
[1,3,0]
[2,3,0]
[0,4,0]
[1,4,0]
[2,4,0]
[0,0,1]
[1,0,1]
[2,0,1]
[0,1,1]
[1,1,1]
[2,1,1]
[0,2,1]
[1,2,1]
[2,2,1]
[0,3,1]
[1,3,1]
[2,3,1]
[0,4,1]
[1,4,1]
[2,4,1]
...
Of course you can extend this scheme to arbitrary dimensions and arbitrary sizes for each dimension
gnibbler
2010-02-23 01:57:04
Might want to bracket the + and *
Preet Sangha
2010-02-23 02:09:40