I have a table with a "points" (or outlining) hierarchy: the fields are L1 L2 L3 L4 L5 (L = level)
For example:
1.0.0.0.0
1.1.0.0.0
1.1.1.0.0
1.1.2.0.0
1.2.0.0.0
If I want to insert a sibling at 1.1.1.0.0 I should get a new row of 1.1.2.0.0 - and the already existing 1.1.2.0.0 should be adjusted up to 1.1.3.0.0, etc.
If I want to insert a child 1.1.1.0.0 I should get a new row of 1.1.1.1.0 with not adjustments required since there are no siblings existing at that level.
I have created procedural code for this - but it is turning into spaghetti - and I want to have an OOP solution with a class that handles these insertions and adjustments.
Can anyone please recommend even pseudo-code for handling these 2 types of insertions and required adjustments to already existing "rows"?
Any help or suggestions would be greatly appreciated!
The people who gave you comments I don't think really understood the issue. You already have a table so using a LinkedList does not do anything more than a table. You really need to pass the method a row to insert and a field to insert. Just adding a new row with value 1.1.1.0.0 does not give enough information to renumber.
The code below I used a DataTable with each column a Field. To make code simply I'm assuming the indexes are integers. Code is not very complicated