Skip to content

Commit 8e3bf36

Browse files
committed
Add ordering in nodes
1 parent c05e9d7 commit 8e3bf36

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

vicutils/printBin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from itertools import product
2+
from functools import total_ordering
23

34
# Default configuration constants
45
DEFAULT_UNIT_SIZE = 3
56
DEFAULT_VALUE_FILL_CHAR = " " # Character used to pad node values (e.g., "_5_")
67
DEFAULT_CONNECTOR_FILL_CHAR = "_" # Character used to fill horizontal gaps between node pairs
78

89

10+
@total_ordering
911
class BinaryNode:
1012
"""
1113
Represents a node in a binary tree.
@@ -64,6 +66,12 @@ def __str__(self):
6466

6567
def __repr__(self):
6668
return str(self)
69+
70+
def __eq__(self, value):
71+
return self.val == value
72+
73+
def __lt__(self, value):
74+
return self.val < value
6775

6876

6977
def center(val, unitSize=None, fillChar=None):

0 commit comments

Comments
 (0)