Is there a way to replace a single element in a list with TWO or more other elements without disturbing the rest of the list ? I understand you can replace one element with another, but i'm looking for more than one element to be added. The use case is that I would like to split a given element into two or more elements based on a particular condition.
For example: Let's say the list contains the path from node A to node F on a Graph as follows: A -> B -> C -> D -> E -> F
I would like to replace node C with two other elements say node X and node Y. The final list should look as follows:
A -> B -> X -> Y -> D -> E -> F
Note: I am still thinking through the implementation and I have not finalized on using any particular type of list (ArrayList, LinkedList etc.) yet.