Skip to content

Commit 3241c85

Browse files
committed
remove static comparable less than
1 parent 8e5920f commit 3241c85

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

src/Interval.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,4 @@ public function getMax(): Interval
8282
{
8383
return $this;
8484
}
85-
86-
public static function comparableLessThan(int $val1, int $val2): bool
87-
{
88-
return $val1 < $val2;
89-
}
9085
}

src/IntervalTree.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getSize(): int
3434
/**
3535
* Returns true if tree is empty
3636
*
37-
* @return boolean
37+
* @return bool
3838
*/
3939
public function isEmpty(): bool
4040
{
@@ -58,7 +58,7 @@ public function iterateIntersections(Interval $interval): Iterator
5858
* Check that interval has intersections
5959
*
6060
* @param Interval $interval
61-
* @return boolean
61+
* @return bool
6262
*/
6363
public function hasIntersection(Interval $interval): bool
6464
{
@@ -366,7 +366,7 @@ private function localMinimum(Node $node): Node
366366
return $nodeMin;
367367
}
368368

369-
public function treeSuccessor(Node $node): ?Node
369+
private function treeSuccessor(Node $node): ?Node
370370
{
371371
if ($node->getRight() !== $this->nilNode) {
372372
$nodeSuccessor = $this->localMinimum($node->getRight());

src/Node.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)