github.com/benz9527/toy-box/algo@v0.0.0-20240221120937-66c0c6bd5abd/list/README.md (about) 1 # Doubly Linked List move function 2 3 ## move src before dst 4 5 6 | src\dst | not in list | the only one | the first but not the last | the last but not the first | in middle | 7 | -------------------------- | ----------- | ------------ | ------------------------------------ | ------------------------------------------------ | --------------------- | 8 | not in list | x | x | x | x | x | 9 | the only one | x | x | x | x | x | 10 | the first but not the last | x | x | x | root.header(src.next)<br /><br /> root.tail(src) | root.header(src.next) | 11 | the last but not the first | x | x | root.header(src) root.tail(src.prev) | x | root.tail(src.prev) | 12 | in middle | x | x | root.header(src) | x | x | 13 14 ## move src after dst 15 16 17 | src\dst | not in list | the only one | the first but not the last | the last but not the first | in middle | 18 | -------------------------- | ----------- | ------------ | ------------------------------------ | ------------------------------------------------ | --------------------- | 19 | not in list | x | x | x | x | x | 20 | the only one | x | x | x | x | x | 21 | the first but not the last | x | x | x | root.header(src.next)<br /><br /> root.tail(src) | root.header(src.next) | 22 | the last but not the first | x | x | root.header(src) root.tail(src.prev) | x | root.tail(src.prev) | 23 | in middle | x | x | x | root.tail(src) | x |