| @@ 55-65 (lines=11) @@ | ||
| 52 | * @param callable $find |
|
| 53 | * @return MapEntry|null |
|
| 54 | */ |
|
| 55 | public function find(callable $find) |
|
| 56 | { |
|
| 57 | /** @var MapEntry $mapEntry */ |
|
| 58 | foreach ($this->entrySet() as $mapEntry) { |
|
| 59 | if (true === $find($mapEntry)) { |
|
| 60 | return $mapEntry; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| 64 | return null; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Use a closure to determine existence in the map |
|
| @@ 76-86 (lines=11) @@ | ||
| 73 | * @param callable $exists |
|
| 74 | * @return bool |
|
| 75 | */ |
|
| 76 | public function exists(callable $exists): bool |
|
| 77 | { |
|
| 78 | /** @var MapEntry $mapEntry */ |
|
| 79 | foreach ($this->entrySet() as $mapEntry) { |
|
| 80 | if (true === $exists($mapEntry)) { |
|
| 81 | return true; |
|
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| 85 | return false; |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||