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
| struct DoublyLinkedList<Element> { | |
| class Node { | |
| var value: Element | |
| weak var next: Node? | |
| var previous: Node? | |
| init(_ value: Element, next: Node?, previous: Node?) { | |
| (self.value, self.next, self.previous) = (value, next, previous) | |
| next?.previous = self | |
| previous?.next = self |
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
| struct Stack<Element> { | |
| fileprivate class Node { | |
| let value: Element | |
| var previousNode: Node? | |
| init(_ value: Element, previousNode: Node?) { | |
| self.value = value | |
| self.previousNode = previousNode | |
| } | |
| } |
NewerOlder