Created
May 11, 2017 18:43
-
-
Save chriswebb09/decaf5f8f56371dfec36d113f5ff9571 to your computer and use it in GitHub Desktop.
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
class LinkedList<T> { | |
public typealias Node = LLNode<T> | |
private var head: Node? | |
private var tail: Node? | |
var isEmpty: Bool { | |
return head == nil | |
} | |
var first: Node? { | |
return head | |
} | |
var last: Node? { | |
return tail | |
} | |
func append(value: T) { | |
let newNode = Node(value: value) | |
if let lastNode = last { | |
newNode.previous = lastNode | |
lastNode.next = newNode | |
} else { | |
head = newNode | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment