Skip to content

Commit e376ff9

Browse files
committed
iterateIntersections -> findIntersections
1 parent 807f9c9 commit e376ff9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/IntervalTree.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ public function isEmpty(): bool
4242
}
4343

4444
/**
45-
* Iterator of nodes which intervals intersect with given interval
45+
* Find nodes which intervals intersect with given interval
4646
* @param Interval $interval
4747
* @return Iterator<Node>
4848
*/
49-
public function iterateIntersections(Interval $interval): Iterator
49+
public function findIntersections(Interval $interval): Iterator
5050
{
5151
$searchNode = Node::withPair(new Pair($interval));
5252
foreach ($this->treeSearchInterval($searchNode) as $node) {
@@ -62,8 +62,8 @@ public function iterateIntersections(Interval $interval): Iterator
6262
*/
6363
public function hasIntersection(Interval $interval): bool
6464
{
65-
$nodesIterator = $this->iterateIntersections($interval);
66-
return $nodesIterator->current() !== null;
65+
$nodes = $this->findIntersections($interval);
66+
return $nodes->current() !== null;
6767
}
6868

6969
/**
@@ -74,8 +74,8 @@ public function hasIntersection(Interval $interval): bool
7474
*/
7575
public function countIntersections(Interval $interval): int
7676
{
77-
$nodesIterator = $this->iterateIntersections($interval);
78-
return iterator_count($nodesIterator);
77+
$nodes = $this->findIntersections($interval);
78+
return iterator_count($nodes);
7979
}
8080

8181
/**

tests/IntervalTreeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testFindAllIntersections(): void
3232
{
3333
$checkInterval = [2, 3];
3434
$overlappingIntervals = [[0, 2], [0, 2], [0, 3], [1, 4], [2, 3], [3, 4]];
35-
$intersections = $this->tree->iterateIntersections(Interval::fromArray($checkInterval));
35+
$intersections = $this->tree->findIntersections(Interval::fromArray($checkInterval));
3636
foreach ($intersections as $index => $node) {
3737
$overlappingInterval = Interval::fromArray($overlappingIntervals[$index]);
3838
$overlappingValue = implode('-', $overlappingIntervals[$index]);

0 commit comments

Comments
 (0)