Last active
March 29, 2018 09:10
-
-
Save Abhishek9634/14bcc3bd1acd2c3edbd1bc7fb4cb2d5c to your computer and use it in GitHub Desktop.
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 TreeNode<T>: Comparable, CustomStringConvertible where T: Comparable, T: CustomStringConvertible { | |
static func <(lhs: TreeNode<T>, rhs: TreeNode<T>) -> Bool { | |
return lhs.data < rhs.data | |
} | |
static func ==(lhs: TreeNode<T>, rhs: TreeNode<T>) -> Bool { | |
return lhs.data == rhs.data | |
} | |
var description: String { | |
return self.data.description | |
} | |
var data: T | |
var leftNode: TreeNode? | |
var rightNode: TreeNode? | |
init(data: T, | |
leftNode: TreeNode? = nil, | |
rightNode: TreeNode? = nil) { | |
self.data = data | |
self.leftNode = leftNode | |
self.rightNode = rightNode | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment