Skip to content

Instantly share code, notes, and snippets.

@Abhishek9634
Last active March 29, 2018 09:10
Show Gist options
  • Save Abhishek9634/14bcc3bd1acd2c3edbd1bc7fb4cb2d5c to your computer and use it in GitHub Desktop.
Save Abhishek9634/14bcc3bd1acd2c3edbd1bc7fb4cb2d5c to your computer and use it in GitHub Desktop.
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