@@ -22,14 +22,16 @@ class Node
2222 /**
2323 * @var NodeColor
2424 */
25- public $ color ;
25+ private $ color ;
2626
2727 /**
2828 * @var Pair
2929 */
3030 private $ pair ;
3131
32- /** @var null|Interval */
32+ /**
33+ * @var null|Interval
34+ */
3335 private $ max ;
3436
3537 private function __construct ()
@@ -47,7 +49,7 @@ public static function withPair(Pair $pair): self
4749
4850 public static function nil (): self
4951 {
50- $ self = new self ;
52+ $ self = new self () ;
5153 $ self ->color = NodeColor::black ();
5254 return $ self ;
5355 }
@@ -136,16 +138,15 @@ public function updateMax(): void
136138 // Other_node does not intersect any node of left subtree, if this.left.max < other_node.item.key.low
137139 public function notIntersectLeftSubtree (Node $ searchNode ): bool
138140 {
139- //const comparable_less_than = this.item.key.constructor.comparable_less_than; // static method
140- $ high = $ this ->left ->max ->getHigh () ?? $ this ->left ->max ;
141- return Interval::comparableLessThan ($ high , $ searchNode ->getPair ()->getInterval ()->getLow ());
141+ $ high = $ this ->getLeft ()->max ->getHigh () ?? $ this ->getLeft ()->getPair ()->getInterval ()->getHigh ();
142+ return $ high < $ searchNode ->getPair ()->getInterval ()->getLow ();
142143 }
143144
144145 // Other_node does not intersect right subtree if other_node.item.key.high < this.right.key.low
145146 public function notIntersectRightSubtree (Node $ searchNode ): bool
146147 {
147148 //const comparable_less_than = this.item.key.constructor.comparable_less_than; // static method
148- $ low = $ this ->right ->max ->getLow () ?? $ this ->right ->getPair ()->getInterval ()->getLow ();
149- return Interval:: comparableLessThan ( $ searchNode ->getPair ()->getInterval ()->getHigh (), $ low) ;
149+ $ low = $ this ->right ->max ->getLow () ?? $ this ->getRight () ->getPair ()->getInterval ()->getLow ();
150+ return $ searchNode ->getPair ()->getInterval ()->getHigh () < $ low ;
150151 }
151152}
0 commit comments