| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace MathPHP\SetTheory;
- /**
- * Immutable Set (Set Theory)
- * A set that cannot be changed once created.
- *
- * Add, remove, and clear do not work on an immutable set. No Exceptions will
- * be thrown; it will just do nothing.
- *
- * Other than that, it acts just like a Set.
- */
- class ImmutableSet extends Set
- {
- /**************************************************************************
- * SINGLE MEMBER OPERATIONS - OVERIDDEN FROM SET
- * - Add (cannot add members)
- * - Add multi (cannot add members)
- * - Remove (cannot remove members)
- * - Remove multi (cannot remove members)
- * - Clear (cannot clear set)
- **************************************************************************/
- /**
- * Cannot add members to an immutable set
- *
- * @param mixed $x
- *
- * @return Set (this set unchanged)
- */
- public function add($x): Set
- {
- return $this;
- }
- /**
- * Cannot add members to an immutable set
- *
- * @param array<mixed> $members
- *
- * @return Set (this set unchanged)
- */
- public function addMulti(array $members): Set
- {
- return $this;
- }
- /**
- * Cannot remove members of an immutable set
- *
- * @param mixed $x
- *
- * @return Set (this set unchanged)
- */
- public function remove($x): Set
- {
- return $this;
- }
- /**
- * Cannot remove members of an immutable set
- *
- * @param array<mixed> $x
- *
- * @return Set (this set unchanged)
- */
- public function removeMulti(array $x): Set
- {
- return $this;
- }
- /**
- * Cannot clear an immutable set
- *
- * @return Set (this set unchanged)
- */
- public function clear(): Set
- {
- return $this;
- }
- }
|