I have a c# object that sets the values of 2 floating point numbers. I have many such objects.
I would like to store these floating point numbers in an array. So the layout would be something like this:
Given a float array: float[] vec = new float[6]
Object 1 sets the values of vec[0] and vec[1]
Object 2 sets the values of vec[2] and vec[3]
Object 3 sets the values of vec[4] and vec[5]
How can I store references on the objects so they will access the correct vector element? I could store an index, but in the old-fashioned c++ world I could store a pointer directly into array.
When I need to use a C-style pointer to the middle of an array, I just make a generic struct that contains a reference to the array and the current index, and use that. Feel free to steal my code:
http://blogs.msdn.com/b/ericlippert/archive/2011/03/10/references-and-pointers-part-two.aspx