| @@ 41-51 (lines=11) @@ | ||
| 38 | * @param callable $find |
|
| 39 | * @return MapEntry|null |
|
| 40 | */ |
|
| 41 | public function find(callable $find) |
|
| 42 | { |
|
| 43 | /** @var MapEntry $mapEntry */ |
|
| 44 | foreach ($this->entrySet() as $mapEntry) { |
|
| 45 | if (true === $find($mapEntry)) { |
|
| 46 | return $mapEntry; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| 50 | return null; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Use a closure to determine existence in the map |
|
| @@ 62-72 (lines=11) @@ | ||
| 59 | * @param callable $exists |
|
| 60 | * @return bool |
|
| 61 | */ |
|
| 62 | public function exists(callable $exists): bool |
|
| 63 | { |
|
| 64 | /** @var MapEntry $mapEntry */ |
|
| 65 | foreach ($this->entrySet() as $mapEntry) { |
|
| 66 | if (true === $exists($mapEntry)) { |
|
| 67 | return true; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| 71 | return false; |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||