MCPcopy Create free account
hub / github.com/F-Stack/f-stack / listRotateHeadToTail

Function listRotateHeadToTail

app/redis-6.2.6/src/adlist.c:346–358  ·  view source on GitHub ↗

Rotate the list removing the head node and inserting it to the tail. */

Source from the content-addressed store, hash-verified

344
345/* Rotate the list removing the head node and inserting it to the tail. */
346void listRotateHeadToTail(list *list) {
347 if (listLength(list) <= 1) return;
348
349 listNode *head = list->head;
350 /* Detach current head */
351 list->head = head->next;
352 list->head->prev = NULL;
353 /* Move it as tail */
354 list->tail->next = head;
355 head->next = NULL;
356 head->prev = list->tail;
357 list->tail = head;
358}
359
360/* Add all the elements of the list 'o' at the end of the
361 * list 'l'. The list 'other' remains empty but otherwise valid. */

Calls

no outgoing calls

Tested by

no test coverage detected