organising lists using hashsets or better approach?

May 15 2014 6:24 AM
Hello everybody,

(I have rearranged my question, I hope now is clearer, I apologise). I have a question regarding how to rearrange lists in an special manner. I have heard about the hashset but I do not fully understand how that thing works or if it is the best option for this issue. Basically I have 3 lists: LIST1, LIST2 and LIST3. LIST1 is a set of xyz points and LIST2 shows how the points are connected in list 1 (e.g point1 -> point 4 -> point 3). Please note that the value -1 at the end of each line in list 2 does not mean anything at the minute but I need to keep it for future usage.

The idea is to get 3 groups of values:

·        Group 1 including all the values that are clockwise (list3) with the points in order in list1 and showing connections starting from zero on in list2.

·        Group 2 including all the values that are counterclockwise (list3) with the points in order in list1 and showing connections starting from zero on in list2.

·        Group 3 including all the values that are coolinear (list3) with the points in order in list1 and showing connections starting from zero on in list2.

The idea is to be able to organise the tables depending on the values in List 3 (0,1, or -1) which will also affect table 2 as indicated in the example below:

The three lists looks initially like this:

     LIST1                  LIST2         LIST3

     0 0 128.5884590855650, 1, 2,-1     1

     25 0 134.979628462965, 1, 4, 2,-1     1

     0 0 134.9796284629652, 4, 5,-1     1

     25 0 128.588459085565, 4, 6, 5,-1     -1

     25 0 140.100717207301, 5, 6, 7,-1     -1

     0 0 140.1007172073016, 8, 7,-1     -1

     25 0 143.874943728927, 8, 9,-1      1

     0 0 143.87494372892,   8, 10, 9,-1       1

     25 0 146.245863353464, 9, 10, 11,-1      1

     0 0 146.24586335346410, 12, 11,-1    -1

     25 0 147.181161545899, 11, 12, 13,-1   -1

     0 0 147.18116154589912, 14, 13,-1   -1

     25 0 146.668001779529, 13, 14, 15,-1   -1

     0 0 146.66800177952914, 16, 15,-1   -1

     25 0 144.711312619297, 15, 16, 17,-1   -1

     0 0 144.71131261929716, 18, 17,-1   -1

     25 0 141.340784276868, 17, 18, 19,-1   -1

     0 0 141.34078427686818, 20, 19,-1   -1

     25 0 136.604499944182, 19, 20, 21,-1   -1

     0 0 136.60449994418220, 22, 21,-1   0

     25 0 130.573315654463, 21, 22, 23,-1   0

     0 0 130.57331565446322, 24, 23,-1   0

     25 0 123.341482952817, 23, 24, 25,-1   -1

     0 0 123.34148295281724, 26, 25,-1   -1

     25 0 115.031289382498, 25, 26, 27,-1   -1

     0 0 115.0312893824980, 3, 1,-1      1

     25 0 105.793445439687,                 1

     0 0 105.793445439687,                  1

Now I will filter which values in list 1 and list 2 correspond to the value 0 in list 3:

     LIST1                    LIST2       LIST3

    0 0 136.604499944182,   20, 22, 21,-1     0

    25 0 130.57331565446321, 22, 23,-1     0

    0 0 130.573315654463,   22, 24, 23,-1     0

However I cannot keep list 2 as shown above. I need to show the list 2 from the beginning (it will contain zero somewhere, then 1,2,3,4 will be placed accordingly. The desired result is as follows:

    LIST1                     LIST2       LIST3

    0 0 136.604499944182,   0, 2, 1,-1     0

    25 0 130.5733156544632, 2, 3,-1     0

    0 0 130.573315654463,   2, 4, 3,-1     0

Hope this is clear enough! Any help will be extremely welcome!!!

Many thanks!!


Answers (45)