Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

TemperWorks/CollectionMacros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CollectionMacros

Macros, for Laravel Collections.

This package currently only contains matchWith

matchWith

matchWith pairs two pre-sorted collections with eachother. It takes a comparator function and callbacks to handle both matched and unmatched items. It does this as efficiently as possible in O(n) by walking through both collections alongside each other.

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"; },
);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages