Implementing a Lookup Table
<p>I am working on a custom data structure and I am currently in the beta testing process: The data will be stored within an array and this array can be represented as a 4D, 2D &amp; 1D array. These three arrays are declared within a union since it represents the same memory addressing. Here is the declaration to my class:</p>

<p><strong>SomeClass.h</strong></p>

<pre><code>#ifndef SomeClass_H
#define SomeClass_H

class SomeClass {
public:
    static const unsigned V1D_SIZE;   // Single Or Linear Array Representation : Size 256 - 256 Elements
    static const unsigned V2D_SIZE;   // 2D Array [16][16]                     : Size 16  - 256 Elements
    static const unsigned V4D_SIZE;   // 4D Array [4][4][4][4]                 : Size 4   - 256 Elements

    enum Index {
        HEX_UNDER_FLOW = -0x01,
        HEX_0 = 0x00,
        HEX_1 = 0x01,
        HEX_2 = 0x02,
        HEX_3 = 0x03,
        HEX_4 = 0x04,
        HEX_5 = 0x05,
        HEX_6 = 0x06,
        HEX_7 = 0x07,
        HEX_8 = 0x08,
        HEX_9 = 0x09,
        HEX_A = 0x0A,
        HEX_B = 0x0B,
        HEX_C = 0x0C,
        HEX_D = 0x0D,
        HEX_E = 0x0E,
        HEX_F = 0x0F,
        HEX_OVER_FLOW = 0x10
    }; // Index

    // Will Be Private After Testing.
    union {
        int m_p256[256];
        int m_p16[16][16];
        int m_p4[4][4][4][4];
    };

private:
    struct CrossReference {
        Index A;
        Index B;

        CrossReference() {}
        CrossReference( const Index&amp; A_, const Index&amp; B_ ) : A(A_), B(B_) {}
    } typedef CR;


    // Current Not Used Only Here To Illustrate A Simple Representation - May Use Or Incorporate Later
    struct Cubes {
        unsigned box;     // 0 - 3    - w
        unsigned slice;   // 0 - 15   - z 
        unsigned row;     // 0 - 15   - y
        unsigned coloumn; // 0 - 15   - x
    } m_cubes;


    CR m_cr[256];

public: 
    SomeClass();
    ~SomeClass();

    const CR&amp; getIndexTable() const;
    void displayIndexTable() const;

private:
    // Must Be Called In Constructor First!
    void initializeCrossReference();

}; // SomeClass

#endif // SomeClass
</code></pre>

<p>I need to generate a reference look up table of coordinate value pairs of this 4D structure to implement its 1D version.</p>

<p>To illustrate the index traversal you can refer to these images for a visual representation:</p>

<p><a href="https://i.stack.imgur.com/cXlkX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cXlkX.png" alt="3D Visual"></a> Note: the {x,y,z,w} in this image does not represent the actual 4D array in memory: it is just a visualization! In Memory the 4D array would be as this: <code>array[box][slice][row][column]</code> and this image represents 1 box within the 4D array.</p>

<p><a href="https://i.stack.imgur.com/NFf7d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NFf7d.png" alt="2D Visual 1D LookUp"></a> Note: This image is a 2D visual representation of all 4 boxes that are described in the top image. The colored text in both images correspond to the appropriate index.</p>

<p>The second image is a 2D flat grid image representation of this 4D array data structure. We can use this image to generate the coordinates for this look up table. </p>

<p>Each quarter of this image represents 1 box. Top Left (starting) is box 0, top right box 1, bottom left box 2, bottom right box 3. Each box, can be broken down the same way for each slice. Top Left (starting) slice 0, top right slice 1, bottom left slice 2, bottom right slice 3. Then when working in each slice the traversal is row - col and once col = 3, we move down to the next row. So after we complete a single slice we have to jump our location depending on the current slices index. The same goes for boxes. </p>

<p>Here are a couple of examples of traversing this table to generate a set of index coordinate values in hex notation:</p>

<pre><code>array[2][3][0][1] our [A,B] hex value would be [0x0C, 0x05] 
array[1][1][3][3] our [A,B] hex value would be [0x03, 0x0F]
</code></pre>

<p>I am in the process of designing a function to generate this look up table. I have done this manually here:</p>

<pre><code>void SomeClass::initializeCrossReference() {
    //////////////////////////////////
    // Upper Half Of Grid Structure //
    //////////////////////////////////  

    //  Grid Coordinates //
    // Linear Or 1D Array Representation - Mapped From type[16][16] which is a 
    // 2D Compressed Version of type[4][4][4][4] - 
    // NOTE: This does not represent 4D Space; it represents a cluster of 4 (3D Cubes). 
    // In the declaration of the class there are two multi deminsional arrays that
    // are shared in memory through a nameless union.

    //      ROW              COL          

    // BOX - 0
    // Slice - 0
    // Row - 0                              // Column Coordinates
    m_cr[0].A  = HEX_0;  m_cr[0].B = HEX_0;  // col 0
    m_cr[1].A  = HEX_0;  m_cr[1].B = HEX_1;  // col 1
    m_cr[2].A  = HEX_0;  m_cr[2].B = HEX_2;  // col 2
    m_cr[3].A  = HEX_0;  m_cr[3].B = HEX_3;  // col 3
    // Row - 1
    m_cr[4].A  = HEX_1;  m_cr[4].B = HEX_0;
    m_cr[5].A  = HEX_1;  m_cr[5].B = HEX_1;
    m_cr[6].A  = HEX_1;  m_cr[6].B = HEX_2;
    m_cr[7].A  = HEX_1;  m_cr[7].B = HEX_3;
    // Row - 2
    m_cr[8].A  = HEX_2;  m_cr[8].B  = HEX_0;
    m_cr[9].A  = HEX_2;  m_cr[9].B  = HEX_1;
    m_cr[10].A = HEX_2;  m_cr[10].B = HEX_2;
    m_cr[11].A = HEX_2;  m_cr[11].B = HEX_3;
    // Row - 3
    m_cr[12].A = HEX_3;  m_cr[12].B = HEX_0;    
    m_cr[13].A = HEX_3;  m_cr[13].B = HEX_1;
    m_cr[14].A = HEX_3;  m_cr[14].B = HEX_2;
    m_cr[15].A = HEX_3;  m_cr[15].B = HEX_3;

    // Slice - 1
    // Row - 0
    m_cr[16].A = HEX_0;  m_cr[16].B = HEX_4;
    m_cr[17].A = HEX_0;  m_cr[17].B = HEX_5;
    m_cr[18].A = HEX_0;  m_cr[18].B = HEX_6;    
    m_cr[19].A = HEX_0;  m_cr[19].B = HEX_7;
    // Row - 1
    m_cr[20].A = HEX_1;  m_cr[20].B = HEX_4;
    m_cr[21].A = HEX_1;  m_cr[21].B = HEX_5;
    m_cr[22].A = HEX_1;  m_cr[22].B = HEX_6;
    m_cr[23].A = HEX_1;  m_cr[23].B = HEX_7;
    // Row - 2;
    m_cr[24].A = HEX_2;  m_cr[24].B = HEX_4;
    m_cr[25].A = HEX_2;  m_cr[25].B = HEX_5;
    m_cr[26].A = HEX_2;  m_cr[26].B = HEX_6;
    m_cr[27].A = HEX_2;  m_cr[27].B = HEX_7;
    // Row - 3
    m_cr[28].A = HEX_3;  m_cr[28].B = HEX_4;
    m_cr[29].A = HEX_3;  m_cr[29].B = HEX_5;
    m_cr[30].A = HEX_3;  m_cr[30].B = HEX_6;
    m_cr[31].A = HEX_3;  m_cr[31].B = HEX_7;

    // Slice - 2
    // Row - 0
    m_cr[32].A = HEX_4;  m_cr[32].B = HEX_0;
    m_cr[33].A = HEX_4;  m_cr[33].B = HEX_1;
    m_cr[34].A = HEX_4;  m_cr[34].B = HEX_2;
    m_cr[35].A = HEX_4;  m_cr[35].B = HEX_3;
    // Row - 1;
    m_cr[36].A = HEX_5;  m_cr[36].B = HEX_0;
    m_cr[37].A = HEX_5;  m_cr[37].B = HEX_1;
    m_cr[38].A = HEX_5;  m_cr[38].B = HEX_2;
    m_cr[39].A = HEX_5;  m_cr[39].B = HEX_3;
    // Row - 2;
    m_cr[40].A = HEX_6;  m_cr[40].B = HEX_0;
    m_cr[41].A = HEX_6;  m_cr[41].B = HEX_1;
    m_cr[42].A = HEX_6;  m_cr[42].B = HEX_2;
    m_cr[43].A = HEX_6;  m_cr[43].B = HEX_3;
    // Row - 3
    m_cr[44].A = HEX_7;  m_cr[44].B = HEX_0;
    m_cr[45].A = HEX_7;  m_cr[45].B = HEX_1;
    m_cr[46].A = HEX_7;  m_cr[46].B = HEX_2;
    m_cr[47].A = HEX_7;  m_cr[47].B = HEX_3;

    // Slice - 3
    // Row - 0
    m_cr[48].A = HEX_4;  m_cr[48].B = HEX_4;
    m_cr[49].A = HEX_4;  m_cr[49].B = HEX_5;
    m_cr[50].A = HEX_4;  m_cr[50].B = HEX_6;
    m_cr[51].A = HEX_4;  m_cr[51].B = HEX_7;
    // Row - 1
    m_cr[52].A = HEX_5;  m_cr[52].B = HEX_4;
    m_cr[53].A = HEX_5;  m_cr[53].B = HEX_5;
    m_cr[54].A = HEX_5;  m_cr[54].B = HEX_6;
    m_cr[55].A = HEX_5;  m_cr[55].B = HEX_7;
    // Row - 2;
    m_cr[56].A = HEX_6;  m_cr[56].B = HEX_4;
    m_cr[57].A = HEX_6;  m_cr[57].B = HEX_5;
    m_cr[58].A = HEX_6;  m_cr[58].B = HEX_6;
    m_cr[59].A = HEX_6;  m_cr[59].B = HEX_7;
    // Row - 3
    m_cr[60].A = HEX_7;  m_cr[60].B = HEX_4;
    m_cr[61].A = HEX_7;  m_cr[61].B = HEX_5;
    m_cr[62].A = HEX_7;  m_cr[62].B = HEX_6;
    m_cr[63].A = HEX_7;  m_cr[63].B = HEX_7;

    // BOX - 1
    // Slice - 0
    // Row - 0
    m_cr[64].A = HEX_0;  m_cr[64].B = HEX_8;
    m_cr[65].A = HEX_0;  m_cr[65].B = HEX_9;
    m_cr[66].A = HEX_0;  m_cr[66].B = HEX_A;
    m_cr[67].A = HEX_0;  m_cr[67].B = HEX_B;
    // Row - 1
    m_cr[68].A = HEX_1;  m_cr[68].B = HEX_8;
    m_cr[69].A = HEX_1;  m_cr[69].B = HEX_9;
    m_cr[70].A = HEX_1;  m_cr[70].B = HEX_A;
    m_cr[71].A = HEX_1;  m_cr[71].B = HEX_B;
    // Row - 2
    m_cr[72].A = HEX_2;  m_cr[72].B = HEX_8;
    m_cr[73].A = HEX_2;  m_cr[73].B = HEX_9;
    m_cr[74].A = HEX_2;  m_cr[74].B = HEX_A;
    m_cr[75].A = HEX_2;  m_cr[75].B = HEX_B;
    // Row - 3
    m_cr[76].A = HEX_3;  m_cr[76].B = HEX_8;
    m_cr[77].A = HEX_3;  m_cr[77].B = HEX_9;
    m_cr[78].A = HEX_3;  m_cr[78].B = HEX_A;
    m_cr[79].A = HEX_3;  m_cr[79].B = HEX_B;

    // Slice - 1
    // Row - 0
    m_cr[80].A = HEX_0;  m_cr[80].B = HEX_C;
    m_cr[81].A = HEX_0;  m_cr[81].B = HEX_D;
    m_cr[82].A = HEX_0;  m_cr[82].B = HEX_E;
    m_cr[83].A = HEX_0;  m_cr[83].B = HEX_F;
    // Row - 1
    m_cr[84].A = HEX_1;  m_cr[84].B = HEX_C;
    m_cr[85].A = HEX_1;  m_cr[85].B = HEX_D;
    m_cr[86].A = HEX_1;  m_cr[86].B = HEX_E;
    m_cr[87].A = HEX_1;  m_cr[87].B = HEX_F;
    // Row - 2
    m_cr[88].A = HEX_2;  m_cr[88].B = HEX_C;
    m_cr[89].A = HEX_2;  m_cr[89].B = HEX_D;
    m_cr[90].A = HEX_2;  m_cr[90].B = HEX_E;
    m_cr[91].A = HEX_2;  m_cr[91].B = HEX_F;
    // Row - 3
    m_cr[92].A = HEX_3;  m_cr[92].B = HEX_C;
    m_cr[93].A = HEX_3;  m_cr[93].B = HEX_D;
    m_cr[94].A = HEX_3;  m_cr[94].B = HEX_E;
    m_cr[95].A = HEX_3;  m_cr[95].B = HEX_F;

    // Slice - 2
    // Row - 0
    m_cr[96].A = HEX_4;  m_cr[96].B = HEX_8;
    m_cr[97].A = HEX_4;  m_cr[97].B = HEX_9;
    m_cr[98].A = HEX_4;  m_cr[98].B = HEX_A;
    m_cr[99].A = HEX_4;  m_cr[99].B = HEX_B;
    // Row - 1
    m_cr[100].A = HEX_5;  m_cr[100].B = HEX_8;
    m_cr[101].A = HEX_5;  m_cr[101].B = HEX_9;
    m_cr[102].A = HEX_5;  m_cr[102].B = HEX_A;
    m_cr[103].A = HEX_5;  m_cr[103].B = HEX_B;
    // Row - 2
    m_cr[104].A = HEX_6;  m_cr[104].B = HEX_8;
    m_cr[105].A = HEX_6;  m_cr[105].B = HEX_9;
    m_cr[106].A = HEX_6;  m_cr[106].B = HEX_A;
    m_cr[107].A = HEX_6;  m_cr[107].B = HEX_B;
    // Row - 3
    m_cr[108].A = HEX_7;  m_cr[108].B = HEX_8;
    m_cr[109].A = HEX_7;  m_cr[109].B = HEX_9;
    m_cr[110].A = HEX_7;  m_cr[110].B = HEX_A;
    m_cr[111].A = HEX_7;  m_cr[111].B = HEX_B;

    // Slice - 3
    // Row - 0
    m_cr[112].A = HEX_4;  m_cr[112].B = HEX_C;
    m_cr[113].A = HEX_4;  m_cr[113].B = HEX_D;
    m_cr[114].A = HEX_4;  m_cr[114].B = HEX_E;
    m_cr[115].A = HEX_4;  m_cr[115].B = HEX_F;
    // Row - 1
    m_cr[116].A = HEX_5;  m_cr[116].B = HEX_C;
    m_cr[117].A = HEX_5;  m_cr[117].B = HEX_D;
    m_cr[118].A = HEX_5;  m_cr[118].B = HEX_E;
    m_cr[119].A = HEX_5;  m_cr[119].B = HEX_F;
    // Row - 2
    m_cr[120].A = HEX_6;  m_cr[120].B = HEX_C;
    m_cr[121].A = HEX_6;  m_cr[121].B = HEX_D;
    m_cr[122].A = HEX_6;  m_cr[122].B = HEX_E;
    m_cr[123].A = HEX_6;  m_cr[123].B = HEX_F;
    // Row - 3
    m_cr[124].A = HEX_7;  m_cr[124].B = HEX_C;
    m_cr[125].A = HEX_7;  m_cr[125].B = HEX_D;
    m_cr[126].A = HEX_7;  m_cr[126].B = HEX_E;
    m_cr[127].A = HEX_7;  m_cr[127].B = HEX_F;

    //////////////////////////////////
    // Lower Half Of Grid Structure //
    //////////////////////////////////

    // Box - 2
    // Slice - 0
    // Row - 0
    m_cr[128].A = HEX_8;  m_cr[128].B = HEX_0;  // col 0
    m_cr[129].A = HEX_8;  m_cr[129].B = HEX_1;  // col 1
    m_cr[130].A = HEX_8;  m_cr[130].B = HEX_2;  // col 2
    m_cr[131].A = HEX_8;  m_cr[131].B = HEX_3;  // col 3
    // Row - 1
    m_cr[132].A = HEX_9;  m_cr[132].B = HEX_0;
    m_cr[133].A = HEX_9;  m_cr[133].B = HEX_1;
    m_cr[134].A = HEX_9;  m_cr[134].B = HEX_2;
    m_cr[135].A = HEX_9;  m_cr[135].B = HEX_3;
    // Row - 2
    m_cr[136].A = HEX_A;  m_cr[136].B = HEX_0;
    m_cr[137].A = HEX_A;  m_cr[137].B = HEX_1;
    m_cr[138].A = HEX_A;  m_cr[138].B = HEX_2;
    m_cr[139].A = HEX_A;  m_cr[139].B = HEX_3;
    // Row - 3
    m_cr[140].A = HEX_B;  m_cr[140].B = HEX_0;
    m_cr[141].A = HEX_B;  m_cr[141].B = HEX_1;
    m_cr[142].A = HEX_B;  m_cr[142].B = HEX_2;
    m_cr[143].A = HEX_B;  m_cr[143].B = HEX_3;

    // Slice - 1
    // Row - 0
    m_cr[144].A = HEX_8;  m_cr[144].B = HEX_4;
    m_cr[145].A = HEX_8;  m_cr[145].B = HEX_5;
    m_cr[146].A = HEX_8;  m_cr[146].B = HEX_6;
    m_cr[147].A = HEX_8;  m_cr[147].B = HEX_7;
    // Row - 1
    m_cr[148].A = HEX_9;  m_cr[148].B = HEX_4;
    m_cr[149].A = HEX_9;  m_cr[149].B = HEX_5;
    m_cr[150].A = HEX_9;  m_cr[150].B = HEX_6;
    m_cr[151].A = HEX_9;  m_cr[151].B = HEX_7;
    // Row - 2;
    m_cr[152].A = HEX_A;  m_cr[152].B = HEX_4;
    m_cr[153].A = HEX_A;  m_cr[153].B = HEX_5;
    m_cr[154].A = HEX_A;  m_cr[154].B = HEX_6;
    m_cr[155].A = HEX_A;  m_cr[155].B = HEX_7;
    // Row - 3
    m_cr[156].A = HEX_B;  m_cr[156].B = HEX_4;
    m_cr[157].A = HEX_B;  m_cr[157].B = HEX_5;
    m_cr[158].A = HEX_B;  m_cr[158].B = HEX_6;
    m_cr[159].A = HEX_B;  m_cr[159].B = HEX_7;

    // Slice - 2
    // Row - 0
    m_cr[160].A = HEX_C;  m_cr[160].B = HEX_0;
    m_cr[161].A = HEX_C;  m_cr[161].B = HEX_1;
    m_cr[162].A = HEX_C;  m_cr[162].B = HEX_2;
    m_cr[163].A = HEX_C;  m_cr[163].B = HEX_3;
    // Row - 1;
    m_cr[164].A = HEX_D;  m_cr[164].B = HEX_0;
    m_cr[165].A = HEX_D;  m_cr[165].B = HEX_1;
    m_cr[166].A = HEX_D;  m_cr[166].B = HEX_2;
    m_cr[167].A = HEX_D;  m_cr[167].B = HEX_3;
    // Row - 2;
    m_cr[168].A = HEX_E;  m_cr[168].B = HEX_0;
    m_cr[169].A = HEX_E;  m_cr[169].B = HEX_1;
    m_cr[170].A = HEX_E;  m_cr[170].B = HEX_2;
    m_cr[171].A = HEX_E;  m_cr[171].B = HEX_3;
    // Row - 3
    m_cr[172].A = HEX_F;  m_cr[172].B = HEX_0;
    m_cr[173].A = HEX_F;  m_cr[173].B = HEX_1;
    m_cr[174].A = HEX_F;  m_cr[174].B = HEX_2;
    m_cr[175].A = HEX_F;  m_cr[175].B = HEX_3;

    // Slice - 3
    // Row - 0
    m_cr[176].A = HEX_C;  m_cr[176].B = HEX_4;
    m_cr[177].A = HEX_C;  m_cr[177].B = HEX_5;
    m_cr[178].A = HEX_C;  m_cr[178].B = HEX_6;
    m_cr[179].A = HEX_C;  m_cr[179].B = HEX_7;
    // Row - 1
    m_cr[180].A = HEX_D;  m_cr[180].B = HEX_4;
    m_cr[181].A = HEX_D;  m_cr[181].B = HEX_5;
    m_cr[182].A = HEX_D;  m_cr[182].B = HEX_6;
    m_cr[183].A = HEX_D;  m_cr[183].B = HEX_7;
    // Row - 2;
    m_cr[184].A = HEX_E;  m_cr[184].B = HEX_4;
    m_cr[185].A = HEX_E;  m_cr[185].B = HEX_5;
    m_cr[186].A = HEX_E;  m_cr[186].B = HEX_6;
    m_cr[187].A = HEX_E;  m_cr[187].B = HEX_7;
    // Row - 3
    m_cr[188].A = HEX_F;  m_cr[188].B = HEX_4;
    m_cr[189].A = HEX_F;  m_cr[189].B = HEX_5;
    m_cr[190].A = HEX_F;  m_cr[190].B = HEX_6;
    m_cr[191].A = HEX_F;  m_cr[191].B = HEX_7;

    // BOX - 3
    // Slice - 0
    // Row - 0
    m_cr[192].A = HEX_8;  m_cr[192].B = HEX_8;
    m_cr[193].A = HEX_8;  m_cr[193].B = HEX_9;
    m_cr[194].A = HEX_8;  m_cr[194].B = HEX_A;
    m_cr[195].A = HEX_8;  m_cr[195].B = HEX_B;
    // Row - 1
    m_cr[196].A = HEX_9;  m_cr[196].B = HEX_8;
    m_cr[197].A = HEX_9;  m_cr[197].B = HEX_9;
    m_cr[198].A = HEX_9;  m_cr[198].B = HEX_A;
    m_cr[199].A = HEX_9;  m_cr[199].B = HEX_B;
    // Row - 2
    m_cr[200].A = HEX_A;  m_cr[200].B = HEX_8;
    m_cr[201].A = HEX_A;  m_cr[201].B = HEX_9;
    m_cr[202].A = HEX_A;  m_cr[202].B = HEX_A;
    m_cr[203].A = HEX_A;  m_cr[203].B = HEX_B;
    // Row - 3
    m_cr[204].A = HEX_B;  m_cr[204].B = HEX_8;
    m_cr[205].A = HEX_B;  m_cr[205].B = HEX_9;
    m_cr[206].A = HEX_B;  m_cr[206].B = HEX_A;
    m_cr[207].A = HEX_B;  m_cr[207].B = HEX_B;

    // Slice - 1
    // Row - 0
    m_cr[208].A = HEX_8;  m_cr[208].B = HEX_C;
    m_cr[209].A = HEX_8;  m_cr[209].B = HEX_D;
    m_cr[210].A = HEX_8;  m_cr[210].B = HEX_E;
    m_cr[211].A = HEX_8;  m_cr[211].B = HEX_F;
    // Row - 1
    m_cr[212].A = HEX_9;  m_cr[212].B = HEX_C;
    m_cr[213].A = HEX_9;  m_cr[213].B = HEX_D;
    m_cr[214].A = HEX_9;  m_cr[214].B = HEX_E;
    m_cr[215].A = HEX_9;  m_cr[215].B = HEX_F;
    // Row - 2
    m_cr[216].A = HEX_A;  m_cr[216].B = HEX_C;
    m_cr[217].A = HEX_A;  m_cr[217].B = HEX_D;
    m_cr[218].A = HEX_A;  m_cr[218].B = HEX_E;
    m_cr[219].A = HEX_A;  m_cr[219].B = HEX_F;
    // Row - 3
    m_cr[220].A = HEX_B;  m_cr[220].B = HEX_C;
    m_cr[221].A = HEX_B;  m_cr[221].B = HEX_D;
    m_cr[222].A = HEX_B;  m_cr[222].B = HEX_E;
    m_cr[223].A = HEX_B;  m_cr[223].B = HEX_F;

    // Slice - 2
    // Row - 0
    m_cr[224].A = HEX_C;  m_cr[224].B = HEX_8;
    m_cr[225].A = HEX_C;  m_cr[225].B = HEX_9;
    m_cr[226].A = HEX_C;  m_cr[226].B = HEX_A;
    m_cr[227].A = HEX_C;  m_cr[227].B = HEX_B;
    // Row - 1
    m_cr[228].A = HEX_D;  m_cr[228].B = HEX_8;
    m_cr[229].A = HEX_D;  m_cr[229].B = HEX_9;
    m_cr[230].A = HEX_D;  m_cr[230].B = HEX_A;
    m_cr[231].A = HEX_D;  m_cr[231].B = HEX_B;
    // Row - 2
    m_cr[232].A = HEX_E;  m_cr[232].B = HEX_8;
    m_cr[233].A = HEX_E;  m_cr[233].B = HEX_9;
    m_cr[234].A = HEX_E;  m_cr[234].B = HEX_A;
    m_cr[235].A = HEX_E;  m_cr[235].B = HEX_B;
    // Row - 3
    m_cr[236].A = HEX_F;  m_cr[236].B = HEX_8;
    m_cr[237].A = HEX_F;  m_cr[237].B = HEX_9;
    m_cr[238].A = HEX_F;  m_cr[238].B = HEX_A;
    m_cr[239].A = HEX_F;  m_cr[239].B = HEX_B;

    // Slice - 3
    // Row - 0
    m_cr[240].A = HEX_C;  m_cr[240].B = HEX_C;
    m_cr[241].A = HEX_C;  m_cr[241].B = HEX_D;
    m_cr[242].A = HEX_C;  m_cr[242].B = HEX_E;
    m_cr[243].A = HEX_C;  m_cr[243].B = HEX_F;
    // Row - 1
    m_cr[244].A = HEX_D;  m_cr[244].B = HEX_C;
    m_cr[245].A = HEX_D;  m_cr[245].B = HEX_D;
    m_cr[246].A = HEX_D;  m_cr[246].B = HEX_E;
    m_cr[247].A = HEX_D;  m_cr[247].B = HEX_F;
    // Row - 2
    m_cr[248].A = HEX_E;  m_cr[248].B = HEX_C;
    m_cr[249].A = HEX_E;  m_cr[249].B = HEX_D;
    m_cr[250].A = HEX_E;  m_cr[250].B = HEX_E;
    m_cr[251].A = HEX_E;  m_cr[251].B = HEX_F;
    // Row - 3
    m_cr[252].A = HEX_F;  m_cr[252].B = HEX_C;
    m_cr[253].A = HEX_F;  m_cr[253].B = HEX_D;
    m_cr[254].A = HEX_F;  m_cr[254].B = HEX_E;
    m_cr[255].A = HEX_F;  m_cr[255].B = HEX_F;

} // initializeCrossReference
</code></pre>

<p>As you can see this function is long, and not very readable. I'm trying to figure out a way to implement this function in an elegant manner and this is where I am stuck. How would I generate this pattern within in few lines of code using for loop/s and a few if statements(if needed)? </p>

<p>Eventually I would like to compress these [A,B] coordinates into a single unsigned char as if [A,B] = [0x0C,0x08] it would be stored as 0xC8 as a byte instead of a pair of enumerations.</p>

<p><strong>EDIT</strong> - Adding a new Image that should help to understand how I am generating my coordinate pairs and the exact order that they must be in within my look up array.</p>

<p><a href="https://i.stack.imgur.com/QHYPC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QHYPC.png" alt="Improved Image"></a></p>

<p><strong>Note:</strong> This question is the post that I'm accepting, and as for the old question here <a href="https://stackoverflow.com/questions/36415462/custom-data-structure-implementing-an-algorithim-to-generate-a-lookup-table">Custom Data Structure: Implementing an algorithim to generate a lookup table [duplicate]</a> is now a dead post, please refer to this one as being the correct one. I was having trouble with my browser last night when I tried to continue to edit the old one. I was planning on deleting it but I will leave it there for historical purposes and let the administration determine whether or not to delete it.</p>