If I have an array of items:
1, 2, 3, 4, 5, 6, 7, 8
I want to select a range of items and move them to another position in the array. For example:
1, 2, 5, 6, 7, 3, 4, 8
Here the 5, 6, 7 segment has been moved to index 2.
What's the most efficient way of doing this, specifically to limit the number of extra array copies. I have a version working, but it's inefficient and forms a central role in my algorithm which I'm trying to optimise.
Thanks.