Swap items in doubly-linked list by their indices in the backing array
I have an array of objects of the following type: struct Node { Node *_pPrev, *_pNext; double *_pData; }; Some of the nodes participate in a doubly-linked list, with _pData!=nullptr for such nodes. There is also a dummy head node with _pNext pointing to the beginning of the list, and _pPrev pointing to the end. The list starts with containing only this head node, and it should be never removed from the list. The doubly-linked list is backed by an array, with initial size equal to the maximum number of nodes in the list. struct Example { Node _nodes[MAXN]; Node _head; }; Now I want to perform