@@ 375-387 (lines=13) @@ | ||
372 | * @param EnumSet $other EnumSet of the same enumeration to produce the union |
|
373 | * @return EnumSet |
|
374 | */ |
|
375 | public function union(EnumSet $other) |
|
376 | { |
|
377 | if ($this->enumeration !== $other->enumeration) { |
|
378 | throw new InvalidArgumentException(sprintf( |
|
379 | 'Other should be of the same enumeration as this %s', |
|
380 | $this->enumeration |
|
381 | )); |
|
382 | } |
|
383 | ||
384 | $clone = clone $this; |
|
385 | $clone->bitset = $this->bitset | $other->bitset; |
|
386 | return $clone; |
|
387 | } |
|
388 | ||
389 | /** |
|
390 | * Produce a new set with enumerators common to both this and other (this & other) |
|
@@ 395-407 (lines=13) @@ | ||
392 | * @param EnumSet $other EnumSet of the same enumeration to produce the intersect |
|
393 | * @return EnumSet |
|
394 | */ |
|
395 | public function intersect(EnumSet $other) |
|
396 | { |
|
397 | if ($this->enumeration !== $other->enumeration) { |
|
398 | throw new InvalidArgumentException(sprintf( |
|
399 | 'Other should be of the same enumeration as this %s', |
|
400 | $this->enumeration |
|
401 | )); |
|
402 | } |
|
403 | ||
404 | $clone = clone $this; |
|
405 | $clone->bitset = $this->bitset & $other->bitset; |
|
406 | return $clone; |
|
407 | } |
|
408 | ||
409 | /** |
|
410 | * Produce a new set with enumerators in this but not in other (this - other) |
|
@@ 415-427 (lines=13) @@ | ||
412 | * @param EnumSet $other EnumSet of the same enumeration to produce the diff |
|
413 | * @return EnumSet |
|
414 | */ |
|
415 | public function diff(EnumSet $other) |
|
416 | { |
|
417 | if ($this->enumeration !== $other->enumeration) { |
|
418 | throw new InvalidArgumentException(sprintf( |
|
419 | 'Other should be of the same enumeration as this %s', |
|
420 | $this->enumeration |
|
421 | )); |
|
422 | } |
|
423 | ||
424 | $clone = clone $this; |
|
425 | $clone->bitset = $this->bitset & ~$other->bitset; |
|
426 | return $clone; |
|
427 | } |
|
428 | ||
429 | /** |
|
430 | * Produce a new set with enumerators in either this and other but not in both (this ^ other) |
|
@@ 435-447 (lines=13) @@ | ||
432 | * @param EnumSet $other EnumSet of the same enumeration to produce the symmetric difference |
|
433 | * @return EnumSet |
|
434 | */ |
|
435 | public function symDiff(EnumSet $other) |
|
436 | { |
|
437 | if ($this->enumeration !== $other->enumeration) { |
|
438 | throw new InvalidArgumentException(sprintf( |
|
439 | 'Other should be of the same enumeration as this %s', |
|
440 | $this->enumeration |
|
441 | )); |
|
442 | } |
|
443 | ||
444 | $clone = clone $this; |
|
445 | $clone->bitset = $this->bitset ^ $other->bitset; |
|
446 | return $clone; |
|
447 | } |
|
448 | ||
449 | /** |
|
450 | * Get ordinal numbers of the defined enumerators as array |