|
4 | 4 |
|
5 | 5 | namespace KaririCode\Contract\DataStructure; |
6 | 6 |
|
| 7 | +use KaririCode\Contract\DataStructure\Behavioral\Countable; |
| 8 | +use KaririCode\Contract\DataStructure\Behavioral\IterableCollection; |
| 9 | + |
7 | 10 | /** |
8 | 11 | * Interface Map. |
9 | 12 | * |
|
16 | 19 | * |
17 | 20 | * @see https://kariricode.org/ |
18 | 21 | */ |
19 | | -interface Map |
| 22 | +interface Map extends Countable, IterableCollection |
20 | 23 | { |
21 | 24 | /** |
22 | | - * Puts a key-value pair into the map. |
| 25 | + * Adds a key-value pair to the map. |
23 | 26 | * |
24 | | - * @param mixed $key the key |
25 | | - * @param mixed $value the value |
| 27 | + * @param mixed $key The key to add |
| 28 | + * @param mixed $value The value to add |
26 | 29 | */ |
27 | 30 | public function put(mixed $key, mixed $value): void; |
28 | 31 |
|
29 | 32 | /** |
30 | | - * Gets a value by its key. |
| 33 | + * Retrieves a value by its key. |
31 | 34 | * |
32 | | - * @param mixed $key the key |
| 35 | + * @param mixed $key The key to retrieve the value for |
33 | 36 | * |
34 | | - * @return mixed the value associated with the key |
| 37 | + * @return mixed The value associated with the key |
35 | 38 | */ |
36 | 39 | public function get(mixed $key): mixed; |
37 | 40 |
|
38 | 41 | /** |
39 | 42 | * Removes a key-value pair from the map. |
40 | 43 | * |
41 | | - * @param mixed $key the key |
| 44 | + * @param mixed $key The key to remove |
42 | 45 | * |
43 | 46 | * @return bool true if the key-value pair was removed, false otherwise |
44 | 47 | */ |
45 | 48 | public function remove(mixed $key): bool; |
| 49 | + |
| 50 | + /** |
| 51 | + * Checks if the map contains a specific key. |
| 52 | + * |
| 53 | + * @param mixed $key The key to check for |
| 54 | + * |
| 55 | + * @return bool true if the key is present, false otherwise |
| 56 | + */ |
| 57 | + public function containsKey(mixed $key): bool; |
| 58 | + |
46 | 59 | /** |
47 | | - * Returns the number of key-value mappings in the map. |
| 60 | + * Returns all keys in the map. |
48 | 61 | * |
49 | | - * @return int the number of key-value mappings |
| 62 | + * @return array The keys in the map |
| 63 | + */ |
| 64 | + public function keys(): array; |
| 65 | + |
| 66 | + /** |
| 67 | + * Returns all values in the map. |
| 68 | + * |
| 69 | + * @return array The values in the map |
| 70 | + */ |
| 71 | + public function values(): array; |
| 72 | + |
| 73 | + /** |
| 74 | + * Clears all key-value pairs from the map. |
50 | 75 | */ |
51 | | - public function size(): int; |
| 76 | + public function clear(): void; |
52 | 77 | } |
0 commit comments