I have 2D static array with a size of 256 X 256.
Array[256][256]
Each Array element is storing two integer values.
Now, the issue is that the program in which I am using this array has to be time efficient. But I have noticed that those elements like Array[1][40]
, Array[34][67]
and Array[80][80]
, they take less time as compared to Array[150][256]
, Array[140][192]
. Thus, the index values greater than 100 takes more time as compared to other.
Is there any other data structure which can help me to achieve constant time access to the value but also takes less time to access
Code:
for( counter1=0; counter1< sizeof(chunk1); ++counter1)
{
IndexEntries &data=IndexTable[chunk1[counter1]][chunk1[counter1+1]];
DoubleTableEntries &GetValue=NewDoubleTable[NextState_chunk1][data.index];
NextState_chunk1= GetValue.Next_State;
++Bcount;
buffer[ Bcount]=NextState_chunk1;
++counter1;
// Code lines skipped
}
The values of chunk1[counter1]
and chunk1[counter1+1]
ranges from 0-255
. Where chunk1[counter1]
and chunk1[counter1+1]
is array of random unsigned characters.