8 namespace Fossology\Lib\Util;
20 $uniqueValues = array_unique($allValues);
21 $valueMultiplicityMap = array();
23 foreach ($uniqueValues as $value) {
25 foreach ($allValues as $candidate) {
26 if ($value == $candidate) {
30 $valueMultiplicityMap[$value] = $count;
33 return $valueMultiplicityMap;
36 public static function callChunked(Closure $callback, $values, $chunkSize)
38 if ($chunkSize <= 0) {
39 throw new \InvalidArgumentException(
'chunk size should be positive');
42 for ($offset = 0; $offset < count($values); $offset += $chunkSize) {
43 $result = array_merge($result,
44 $callback(array_slice($values, $offset, $chunkSize)));
49 public static function multiSearch($needles,$haystack)
51 foreach ($needles as $needle) {
52 $index = array_search($needle, $haystack);
53 if ($index !==
false) {
75 return !array_diff_key(array_flip($keys), $array);
85 public static function getArrayDiffs(array $oldArray, array $newArray): array
90 $oldSet = array_flip($oldArray);
91 $newSet = array_flip($newArray);
93 foreach ($newArray as $item) {
94 if (!isset($oldSet[$item])) {
99 foreach ($oldArray as $item) {
100 if (!isset($newSet[$item])) {
static arrayKeysExists(array $array, array $keys)
Check if a list of keys exists in associative array.
static getMultiplicityOfValues($allValues)
static getArrayDiffs(array $oldArray, array $newArray)
Get list of additions/removals to make $oldArray equal to $newArray.