Prechádzať zdrojové kódy

Added list circularization

Samuel W. Flint 7 rokov pred
rodič
commit
6aa4785bf7
1 zmenil súbory, kde vykonal 10 pridanie a 0 odobranie
  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;
+}