1 | <?php |
||
18 | class HashSet extends AbstractSet |
||
19 | { |
||
20 | /** |
||
21 | * The data storage |
||
22 | * |
||
23 | * @var MapInterface |
||
24 | */ |
||
25 | protected $map; |
||
26 | |||
27 | /** |
||
28 | * Constructor |
||
29 | * |
||
30 | * Use [@see AbstractSet::add] to ensure uniqueness |
||
31 | * |
||
32 | * @param array $elements |
||
33 | */ |
||
34 | public function __construct(array $elements = null) |
||
42 | |||
43 | /** |
||
44 | * Adds the element to the collection if it doesn't exist |
||
45 | * |
||
46 | * @param mixed $element |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function add($element): bool |
||
60 | |||
61 | /** |
||
62 | * Returns true if the collection contains element |
||
63 | * |
||
64 | * @param mixed $element |
||
65 | * @return bool |
||
66 | */ |
||
67 | public function contains($element): bool |
||
73 | |||
74 | /** |
||
75 | * Removes all elements from a collection |
||
76 | * |
||
77 | * @return void |
||
78 | */ |
||
79 | public function clear(): void |
||
83 | |||
84 | /** |
||
85 | * Remove all items from this collection that don't exist in specified array |
||
86 | * |
||
87 | * Returns true if the collection was modified |
||
88 | * |
||
89 | * @param array $collection |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function retainAllArray(array $collection): bool |
||
105 | |||
106 | /** |
||
107 | * Removes object if it exists |
||
108 | * |
||
109 | * Returns true if the element was removed |
||
110 | * |
||
111 | * @param mixed $element |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function remove($element): bool |
||
122 | |||
123 | /** |
||
124 | * Returns an array of all elements in the collection |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | public function toArray(): array |
||
132 | |||
133 | /** |
||
134 | * Retrieve an external iterator |
||
135 | * |
||
136 | * @return ArrayIterator |
||
137 | */ |
||
138 | public function getIterator(): ArrayIterator |
||
142 | |||
143 | /** |
||
144 | * Return the key to use for the HashMap |
||
145 | * |
||
146 | * @param mixed $element |
||
147 | * @return mixed |
||
148 | */ |
||
149 | protected function getKey($element) |
||
153 | } |
||
154 |