This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Finding and getting data from a static table (Vectorized Data Query)

I have a big table which inclues values according to parameters like x and y. How can i find a values fast enough without high cpu load?

Parents
  • That is a one-dimensional lookup, and it seems like all x values between 1 and 192 are represented. So instant lookup...

    struct {
        unsigned y,z;
    } my_table[] = {
        {11,23},
        {10,22},
        ...
    };
    
    my_y_result = my_table[x-1].y;
    my_z_result = my_table[x-1].z;
    

    You may optionally define y = 0 and z = 1 and have a two-dimensional array:

    unsigned my_array[][2] = {
        {11,23},
        {10,22},
        ...
    };
    
    my_y_result = my_table[x-1][0];
    my_z_result = my_table[x-1][1];
    

Reply
  • That is a one-dimensional lookup, and it seems like all x values between 1 and 192 are represented. So instant lookup...

    struct {
        unsigned y,z;
    } my_table[] = {
        {11,23},
        {10,22},
        ...
    };
    
    my_y_result = my_table[x-1].y;
    my_z_result = my_table[x-1].z;
    

    You may optionally define y = 0 and z = 1 and have a two-dimensional array:

    unsigned my_array[][2] = {
        {11,23},
        {10,22},
        ...
    };
    
    my_y_result = my_table[x-1][0];
    my_z_result = my_table[x-1][1];
    

Children
No data