Skip to content

Instantly share code, notes, and snippets.

@cruffenach
Created October 25, 2014 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cruffenach/0d8e53475f0e4bd018e0 to your computer and use it in GitHub Desktop.
Save cruffenach/0d8e53475f0e4bd018e0 to your computer and use it in GitHub Desktop.
Single Linked List Node
class SingleLinkedListNode <T : Printable> : Printable {
var next : LinkedListNode?
var data : T
init(data : T) {
self.data = data
}
var description : String {
get {
var result = ""
var current : LinkedListNode? = self
while (current != nil) {
if let _current = current {
result += _current.data.description
current = _current.next
if (current != nil) {
result += "-->"
}
}
}
return result
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment