Explorar o código

Added list circularization

Samuel W. Flint %!s(int64=8) %!d(string=hai) anos
pai
achega
6aa4785bf7
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      linkedList.h

+ 10 - 0
linkedList.h

@@ -48,3 +48,13 @@ LISTEL * insertAfter(void *theData, LISTEL *place)
     }
   return element;
 }
+
+LISTEL * circularizeList(LISTEL *start)
+{
+  LISTEL *tail = start;
+  while (tail->next != NULL)
+    tail = tail->next;
+  start->previous = tail;
+  tail->next = start;
+  return start;
+}