I have an array:
WeirdObject[] Things ;
Now lets say I want to keep track of some of those elements of the array that have a property of Things[i].xCoordinate = 5;
I have been using another array with 12 elements because there can be no more then 12 Things that fit the criteria at one time but there can be as little as 0. I have been holding -1 for what I would call an "Empty" Element.
So if Things.Length == 77; I could end up with say 3 with .xCoordinate == 5;
HoldData[0] = 18
HoldData[1] = 12
HoldData[2] = 52
HoldData[3] = -1
HoldData[4] = -1
HoldData[5] = -1
HoldData[6] = -1
HoldData[7] = -1
HoldData[8] = -1
HoldData[9] = -1
HoldData[10] = -1
HoldData[11] = -1
Then use the HoldData Array to manipulate those 3 Things. Maybe even add to and take away from that set. When done with the set, just reset all to -1.
Now the question...Is there a better way? This has a lot of over head and looping and checking and I just feel that there is a method/concept that I am just not familiar with.
Thanks in advance
WeirdObject[] Things ;
Now lets say I want to keep track of some of those elements of the array that have a property of Things[i].xCoordinate = 5;
I have been using another array with 12 elements because there can be no more then 12 Things that fit the criteria at one time but there can be as little as 0. I have been holding -1 for what I would call an "Empty" Element.
So if Things.Length == 77; I could end up with say 3 with .xCoordinate == 5;
HoldData[0] = 18
HoldData[1] = 12
HoldData[2] = 52
HoldData[3] = -1
HoldData[4] = -1
HoldData[5] = -1
HoldData[6] = -1
HoldData[7] = -1
HoldData[8] = -1
HoldData[9] = -1
HoldData[10] = -1
HoldData[11] = -1
Then use the HoldData Array to manipulate those 3 Things. Maybe even add to and take away from that set. When done with the set, just reset all to -1.
Now the question...Is there a better way? This has a lot of over head and looping and checking and I just feel that there is a method/concept that I am just not familiar with.
Thanks in advance
Comment