Created
October 25, 2014 22:39
-
-
Save cruffenach/0d8e53475f0e4bd018e0 to your computer and use it in GitHub Desktop.
Single Linked List Node
This file contains 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 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