I'm trying to implement a three layer deep data structure. It is easy to do until you add the requirement of being able to move around the children and or fields, then it becomes a nightmare.
Parent(Index, ID) -> Children(Index) -> Fields(Index, string)
So for example, the data might look like this:
- Block1 ("Block1")
- Child1
- Field1 ("Hello")
- Field2 ("World")
- Child2
- Field1 ("One")
- Field2 ("Two")
- Field3 ("Three")
- Block2 ("Block2")
- Child1
Now I can implement this by making structs containing an ArrayList and String for both the Parent and Field, and just an Arraylist for Children, but when I need to for example invert Field1 and Field2 it becomes difficult and expensive.
This entire thing seems like it might be easy in a language like C++, since I could dump all the fields into a giant data block and then use pointers to reference where the fields are... Then if I want to switch fields, children, or parents, I just have to change the pointer, and it is cheap.
Has anyone seen this kind of data pattern in C# before? Is there a "standard" way to implement this?