Browse Source

Added facility to remove an element from a list

Samuel W. Flint 7 years ago
parent
commit
609a085e37
1 changed files with 11 additions and 0 deletions
  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;
+}