mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-16 08:28:41 +00:00
impl. early return
This commit is contained in:
parent
50ca46b5a9
commit
ebd709d4cb
|
|
@ -45,7 +45,10 @@ final class MonotoneChain
|
|||
*/
|
||||
public static function createConvexHull(array $points) : array
|
||||
{
|
||||
if (($n = \count($points)) > 1) {
|
||||
if (($n = \count($points)) < 2) {
|
||||
return $points;
|
||||
}
|
||||
|
||||
\uasort($points, [self::class, 'sort']);
|
||||
|
||||
$k = 0;
|
||||
|
|
@ -71,12 +74,10 @@ final class MonotoneChain
|
|||
|
||||
\ksort($result);
|
||||
|
||||
/** @return array<int, array{x:int|float, y:int|float}> */
|
||||
return \array_slice($result, 0, $k - 1);
|
||||
}
|
||||
|
||||
return $points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counter clock wise turn?
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user