This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace { | ||
exit("This file should not be included, only analyzed by your IDE"); | ||
} | ||
|
||
|
||
namespace Illuminate\Support { | ||
|
||
/** | ||
* Class Collection | ||
* @package Illuminate\Support | ||
*/ | ||
class Collection | ||
{ | ||
|
||
/** | ||
* Matches two sorted collections based on a comparator callable with O(m+n) efficiency | ||
* Accepts callables for matched pairs as well as unmatched elements (on both sides) | ||
* Collections can have ordered duplicates, all permutations become matched pairs | ||
* | ||
* Example: | ||
* ```php | ||
* collect([ 1,2,4,7,8,9,14 ]))->matchWith( | ||
* collect([ 1,2,5,6,8,10,11,13,14 ]), | ||
* function($a, $b) { return $a <=> $b; }, | ||
* function($a, $b) { echo "$a matches $b"; }, | ||
* function($a) { echo "$a was not found in b"; }, | ||
* function($b) { echo "$b was not found in a"; }, | ||
* ); | ||
* ``` | ||
* | ||
* @param Collection $b A collection to match up with | ||
* @param callable $comparator A comparator function, to match orderable elements using a <=> b | ||
* @param callable $matched A callback to be executed on each matched pair | ||
* @param callable $unmatchedA A callback to be executed for each unmatched item in the a collection | ||
* @param callable $unmatchedB A callback to be executed on each unmatched item in the b collection | ||
* @return $this | ||
*/ | ||
public function matchWith(Collection $b, callable $comparator, callable $matched, callable $unmatchedA = null, callable $unmatchedB = null): self | ||
{ | ||
return $this; | ||
} | ||
} | ||
} |