코드 수정

This commit is contained in:
2020-05-01 18:24:05 +09:00
parent ef5dd47604
commit c8d2050c7a
11 changed files with 63 additions and 157 deletions
+20 -3
View File
@@ -685,8 +685,25 @@ class Util extends \utilphp\util
* 길이가 다른 경우, 앞의 결과를 먼저 비교한 뒤, 짧은쪽의 값을 null으로 가정하여 길이 처리
*/
public static function arrayCompare(iterable $lhs, iterable $rhs, ?callable $comp=null){
$lhsIter = new \Iterator($lhs);
$rhsIter = new \Iterator($rhs);
if($lhs instanceof \Traversable){
$lhsIter = new \IteratorIterator($lhs);
}
else if(is_array($lhs)){
$lhsIter = new \ArrayIterator($lhs);
}
else{
throw new \InvalidArgumentException('$lhs is not Traversable');
}
if($rhs instanceof \Traversable){
$rhsIter = new \IteratorIterator($rhs);
}
else if(is_array($rhs)){
$rhsIter = new \ArrayIterator($rhs);
}
else{
throw new \InvalidArgumentException('$rhs is not Traversable');
}
while($lhsIter->valid() && $rhsIter->valid()){
$lhsVal = $lhsIter->current();
@@ -759,7 +776,7 @@ class Util extends \utilphp\util
* @param null|int $to
* @param null|int $step
* @return \Traversable
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
public static function range(int $from, ?int $to=null, ?int $step=null):\Traversable{
if($to === null){