Created
May 11, 2017 08:30
-
-
Save chriswebb09/e2f69e2ce4e6e04ee2b0ca775494b6a3 to your computer and use it in GitHub Desktop.
Remove Linked List Node At Index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func remove(node: Node) -> T { | |
| let prev = node.previous | |
| let next = node.next | |
| if let prev = prev { | |
| prev.next = next | |
| } else { | |
| head = next | |
| } | |
| next?.previous = prev | |
| node.previous = nil | |
| node.next = nil | |
| return node.value | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment