1 | <?php |
||
16 | class HashMap implements MapInterface |
||
17 | { |
||
|
|||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $array; |
||
22 | |||
23 | /** |
||
24 | * Constructs a HashTable. A standard php array may be passed in as starting data. |
||
25 | * HashMap only uses a copy of the passed in array, so changes made by the HashMap |
||
26 | * will NOT be reflected in the original array, and vice-versa |
||
27 | * @param array $array |
||
28 | */ |
||
29 | public function __construct($array = null) |
||
38 | |||
39 | /** |
||
40 | * Removes all of the mappings from this map. |
||
41 | */ |
||
42 | public function clear() |
||
46 | |||
47 | /** |
||
48 | * Returns true if this map contains a mapping for the specified key. |
||
49 | * @param multitype $key |
||
50 | * @return boolean |
||
51 | */ |
||
52 | public function containsKey($key) |
||
56 | |||
57 | /** |
||
58 | * Returns true if this map maps one or more keys to the specified value. |
||
59 | * @param unknown $value |
||
60 | * @return boolean |
||
61 | */ |
||
62 | public function containsValue($value) |
||
66 | |||
67 | /** |
||
68 | * Returns a Set view of the mappings contained in this map. |
||
69 | * @return SetInterface |
||
70 | */ |
||
71 | public function entrySet() |
||
75 | |||
76 | /** |
||
77 | * Compares the specified object with this map for equality. |
||
78 | * @return boolean |
||
79 | */ |
||
80 | public function equals($object) |
||
84 | |||
85 | /** |
||
86 | * Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. |
||
87 | * @param multitype $key |
||
88 | * @return multitype |
||
89 | */ |
||
90 | public function get($key) |
||
98 | |||
99 | /** |
||
100 | * Returns the hash code value for this map. |
||
101 | * @return string |
||
102 | */ |
||
103 | public function hashCode() |
||
107 | |||
108 | /** |
||
109 | * Returns true if this map contains no key-value mappings. |
||
110 | * @return boolean |
||
111 | */ |
||
112 | public function isEmpty() |
||
116 | |||
117 | /** |
||
118 | * Returns a Set view of the keys contained in this map. |
||
119 | * @return SetInterface |
||
120 | */ |
||
121 | public function keySet() |
||
125 | |||
126 | /** |
||
127 | * Associates the specified value with the specified key in this map (optional operation). |
||
128 | * @param multitype $key |
||
129 | * @param multitype $value |
||
130 | * @return multitype |
||
131 | */ |
||
132 | public function put($key, $value) |
||
136 | |||
137 | /** |
||
138 | * Copies all of the mappings from the specified map to this map (optional operation). |
||
139 | * @param MapInterface $map |
||
140 | * @return void |
||
141 | */ |
||
142 | public function putAll(MapInterface $map) |
||
149 | |||
150 | /** |
||
151 | * Removes the mapping for a key from this map if it is present |
||
152 | * It returns the previous value associated with key, |
||
153 | * or null if there was no mapping for key. |
||
154 | * (A null return can also indicate that the map previously associated null with key.) |
||
155 | * @param unknown $key |
||
156 | * @return multitype $value | null |
||
157 | */ |
||
158 | public function remove($key) |
||
172 | |||
173 | /** |
||
174 | * Returns the number of key-value mappings in this map. |
||
175 | * @return int |
||
176 | */ |
||
177 | public function size() |
||
181 | |||
182 | /** |
||
183 | * Returns a Collection view of the values contained in this map. |
||
184 | * @return CollectionInterface |
||
185 | */ |
||
186 | public function values() |
||
190 | |||
191 | /********************************************* |
||
192 | ** Array Access Methods |
||
193 | *********************************************/ |
||
194 | |||
195 | /** |
||
196 | * |
||
197 | * {@inheritDoc} |
||
198 | * @see ArrayAccess::offsetExists() |
||
199 | */ |
||
200 | public function offsetExists($offset) |
||
204 | |||
205 | /** |
||
206 | * |
||
207 | * {@inheritDoc} |
||
208 | * @see ArrayAccess::offsetGet() |
||
209 | */ |
||
210 | public function offsetGet($offset) |
||
214 | |||
215 | /** |
||
216 | * |
||
217 | * {@inheritDoc} |
||
218 | * @see ArrayAccess::offsetSet() |
||
219 | */ |
||
220 | public function offsetSet($offset, $value) |
||
228 | |||
229 | /** |
||
230 | * |
||
231 | * {@inheritDoc} |
||
232 | * @see ArrayAccess::offsetUnset() |
||
233 | */ |
||
234 | public function offsetUnset($offset) |
||
238 | |||
239 | } |