Rotate the list removing the tail node and inserting it to the head. */
| 329 | |
| 330 | /* Rotate the list removing the tail node and inserting it to the head. */ |
| 331 | void listRotateTailToHead(list *list) { |
| 332 | if (listLength(list) <= 1) return; |
| 333 | |
| 334 | /* Detach current tail */ |
| 335 | listNode *tail = list->tail; |
| 336 | list->tail = tail->prev; |
| 337 | list->tail->next = NULL; |
| 338 | /* Move it as head */ |
| 339 | list->head->prev = tail; |
| 340 | tail->prev = NULL; |
| 341 | tail->next = list->head; |
| 342 | list->head = tail; |
| 343 | } |
| 344 | |
| 345 | /* Rotate the list removing the head node and inserting it to the tail. */ |
| 346 | void listRotateHeadToTail(list *list) { |