| 397 | |
| 398 | |
| 399 | class Node(object): |
| 400 | def __init__(self, key, val): |
| 401 | self.key = key |
| 402 | self.val = val |
| 403 | self.left = None |
| 404 | self.right = None |
| 405 | |
| 406 | def __gt__(self, other): |
| 407 | """Greater than""" |
| 408 | if not isinstance(other, Node): |
| 409 | return -1 |
| 410 | return self.val > other.val |
| 411 | |
| 412 | def __ge__(self, other): |
| 413 | """Greater than or equal to""" |
| 414 | if not isinstance(other, Node): |
| 415 | return -1 |
| 416 | return self.val >= other.val |
| 417 | |
| 418 | def __lt__(self, other): |
| 419 | """Less than""" |
| 420 | if not isinstance(other, Node): |
| 421 | return -1 |
| 422 | return self.val < other.val |
| 423 | |
| 424 | def __le__(self, other): |
| 425 | """Less than or equal to""" |
| 426 | if not isinstance(other, Node): |
| 427 | return -1 |
| 428 | return self.val <= other.val |
| 429 | |
| 430 | |
| 431 | class HuffmanEncoder(object): |