You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Linked List/README.markdown
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -465,9 +465,7 @@ This loops through the entire list and simply swaps the `next` and `previous` po
465
465
nil <---| |--->| |--->| |--->| |<--- head
466
466
+--------+ +--------+ +--------+ +--------+
467
467
468
-
You may be wondering why the last statement says `node = node!.previous` to go to the next node instead of `node!.next` like you'd expect, but remember that we just swapped those pointers!
469
-
470
-
> **Note:** I couldn't find a way to make this code more Swift-like, without the forced unwrapping. Suggestions for improvements are welcome!
468
+
You may be wondering why the last statement says `node = currentNode.previous` to go to the next node instead of `currentNode.next` like you'd expect, but remember that we just swapped those pointers!
471
469
472
470
Arrays have `map()` and `filter()` functions, and there's no reason why linked lists shouldn't either.
0 commit comments