Преглед на файлове

Added facility to remove an element from a list

Samuel W. Flint преди 7 години
родител
ревизия
609a085e37
променени са 1 файла, в които са добавени 11 реда и са изтрити 0 реда
  1. 11 0
      linkedList.h

+ 11 - 0
linkedList.h

@@ -58,3 +58,14 @@ LISTEL * circularizeList(LISTEL *start)
   tail->next = start;
   return start;
 }
+
+void * removeElement(LISTEL *remove)
+{
+  LISTEL *before = remove->previous;
+  LISTEL *after = remove->next;
+  void * value = remove->data;
+  before->next = after;
+  after->previous = before;
+  free(remove);
+  return value;
+}