| 1 | <?php |
||
| 16 | class ArraySet extends AbstractSet |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * The set elements |
||
| 20 | * |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | private $elements = []; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Constructor |
||
| 27 | * |
||
| 28 | * @param array $elements |
||
| 29 | */ |
||
| 30 | public function __construct(array $elements = []) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Ensure the element exists in the collection |
||
| 37 | * |
||
| 38 | * Returns true if the collection can contain duplicates, |
||
| 39 | * and false if it cannot. |
||
| 40 | * |
||
| 41 | * @param mixed $element |
||
| 42 | * @return bool |
||
| 43 | */ |
||
| 44 | public function add($element): bool |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Removes all elements from a collection |
||
| 57 | * |
||
| 58 | * @return void |
||
| 59 | */ |
||
| 60 | public function clear(): void |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Removes object if it exists |
||
| 67 | * |
||
| 68 | * Returns true if the element was removed |
||
| 69 | * |
||
| 70 | * @param mixed $element |
||
| 71 | * @return bool |
||
| 72 | */ |
||
| 73 | public function remove($element): bool |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Returns an array of all elements in the collection |
||
| 86 | * |
||
| 87 | * @return array |
||
| 88 | */ |
||
| 89 | public function toArray(): array |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Retrieve an external iterator |
||
| 96 | * |
||
| 97 | * @return ArrayIterator |
||
| 98 | */ |
||
| 99 | public function getIterator(): ArrayIterator |
||
| 103 | } |
||
| 104 |