1 | <?php |
||
25 | abstract class AbstractMap |
||
26 | extends AbstractCollection |
||
27 | implements MapInterface |
||
28 | { |
||
29 | /** |
||
30 | * Adds an element to the Map |
||
31 | * |
||
32 | * @param KeyType $key The key to add |
||
33 | * @param ValueType $value The value to add |
||
34 | */ |
||
35 | public function offsetSet($key, $value) |
||
36 | { |
||
37 | $this->add($key, $value); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Adds an element to the Map |
||
42 | * |
||
43 | * @param KeyType $key The key to add |
||
44 | * @param ValueType $value The value to add |
||
45 | */ |
||
46 | 1 | public function add($key, $value) |
|
47 | { |
||
48 | 1 | $this->insert(new Pair($key, $value)); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Checks if a key exists |
||
53 | * |
||
54 | * @param KeyType $key The key to search for |
||
55 | * @return boolean |
||
56 | */ |
||
57 | public function offsetExists($key) : bool |
||
61 | |||
62 | /** |
||
63 | * Removes an item from the map |
||
64 | * |
||
65 | * @param KeyType $key The key of the keypair to remove |
||
66 | */ |
||
67 | public function offsetUnset($key) |
||
71 | |||
72 | /** |
||
73 | * Gets an item from the map, looking it up by the specified key |
||
74 | * |
||
75 | * @param KeyType $key |
||
76 | * @return ValueType |
||
77 | */ |
||
78 | public function offsetGet($key) |
||
82 | } |
||
83 |