class Set
A set is a collection that contains no duplicate elements.
Great care must be exercised if mutable objects are used as set elements. The behavior of a set is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is an element in the set.
Example usage:
``` php $foo = new \My\Foo(); $set = new Set(\My\Foo::class);
$set->add($foo); // returns TRUE, the element doesn't exist $set->add($foo); // returns FALSE, the element already exists
$bar = new \My\Foo(); $set->add($bar); // returns TRUE, $bar !== $foo ```
@template T @extends AbstractSet<T>
Hierarchy
- class \Ramsey\Collection\AbstractArray implements \Ramsey\Collection\ArrayInterface
- class \Ramsey\Collection\AbstractCollection extends \Ramsey\Collection\AbstractArray implements \Ramsey\Collection\CollectionInterface uses \Ramsey\Collection\Tool\TypeTrait, \Ramsey\Collection\Tool\ValueToStringTrait, \Ramsey\Collection\Tool\ValueExtractorTrait
- class \Ramsey\Collection\AbstractSet extends \Ramsey\Collection\AbstractCollection
- class \Ramsey\Collection\Set extends \Ramsey\Collection\AbstractSet
- class \Ramsey\Collection\AbstractSet extends \Ramsey\Collection\AbstractCollection
- class \Ramsey\Collection\AbstractCollection extends \Ramsey\Collection\AbstractArray implements \Ramsey\Collection\CollectionInterface uses \Ramsey\Collection\Tool\TypeTrait, \Ramsey\Collection\Tool\ValueToStringTrait, \Ramsey\Collection\Tool\ValueExtractorTrait
Expanded class hierarchy of Set
17 string references to 'Set'
- AbstractConfigurator::__call in vendor/
symfony/ dependency-injection/ Loader/ Configurator/ AbstractConfigurator.php - ArrayLoader::configureCachedLinks in vendor/
composer/ composer/ src/ Composer/ Package/ Loader/ ArrayLoader.php - ArrayLoader::load in vendor/
composer/ composer/ src/ Composer/ Package/ Loader/ ArrayLoader.php - @inheritDoc
- AsymmetricVisibilityTokenEmulator::emulate in vendor/
nikic/ php-parser/ lib/ PhpParser/ Lexer/ TokenEmulator/ AsymmetricVisibilityTokenEmulator.php - FieldDescriptor::getFieldDescriptor in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ FieldDescriptor.php
File
-
vendor/
ramsey/ collection/ src/ Set.php, line 41
Namespace
Ramsey\CollectionView source
class Set extends AbstractSet {
/**
* Constructs a set object of the specified type, optionally with the
* specified data.
*
* @param string $setType The type or class name associated with this set.
* @param array<array-key, T> $data The initial items to store in the set.
*/
public function __construct(string $setType, array $data = []) {
parent::__construct($data);
}
public function getType() : string {
return $this->setType;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
AbstractArray::$data | protected | property | The items of this array. | ||
AbstractArray::clear | public | function | Removes all items from this array. | Overrides ArrayInterface::clear | |
AbstractArray::count | public | function | Returns the number of items in this array. | ||
AbstractArray::getIterator | public | function | Returns an iterator for this array. | 2 | |
AbstractArray::isEmpty | public | function | Returns `true` if this array is empty. | Overrides ArrayInterface::isEmpty | |
AbstractArray::offsetExists | public | function | Returns `true` if the given offset exists in this array. | ||
AbstractArray::offsetGet | public | function | Returns the value at the specified offset. | ||
AbstractArray::offsetUnset | public | function | Removes the given offset and its value from the array. | ||
AbstractArray::toArray | public | function | @inheritDoc | Overrides ArrayInterface::toArray | 1 |
AbstractArray::__serialize | public | function | Returns data suitable for PHP serialization. | 1 | |
AbstractArray::__unserialize | public | function | Adds unserialized data to the object. | ||
AbstractCollection::column | public | function | @inheritDoc | Overrides CollectionInterface::column | |
AbstractCollection::compareCollectionTypes | private | function | |||
AbstractCollection::contains | public | function | Returns `true` if this collection contains the specified element. | Overrides CollectionInterface::contains | |
AbstractCollection::diff | public | function | Overrides CollectionInterface::diff | ||
AbstractCollection::filter | public | function | Overrides CollectionInterface::filter | ||
AbstractCollection::first | public | function | Overrides CollectionInterface::first | ||
AbstractCollection::getComparator | private | function | |||
AbstractCollection::getUniformType | private | function | |||
AbstractCollection::intersect | public | function | Overrides CollectionInterface::intersect | ||
AbstractCollection::last | public | function | Overrides CollectionInterface::last | ||
AbstractCollection::map | public | function | @template TCallbackReturn | Overrides CollectionInterface::map | |
AbstractCollection::merge | public | function | Overrides CollectionInterface::merge | ||
AbstractCollection::reduce | public | function | @template TCarry | Overrides CollectionInterface::reduce | |
AbstractCollection::remove | public | function | Removes a single instance of the specified element from this collection, if it is present. |
Overrides CollectionInterface::remove | |
AbstractCollection::sort | public | function | Overrides CollectionInterface::sort | ||
AbstractCollection::where | public | function | Overrides CollectionInterface::where | ||
AbstractSet::add | public | function | Ensures that this collection contains the specified element (optional operation). |
Overrides AbstractCollection::add | |
AbstractSet::offsetSet | public | function | Sets the given value to the given offset in the array. | Overrides AbstractCollection::offsetSet | |
Set::getType | public | function | Returns the type associated with this collection. | Overrides CollectionInterface::getType | |
Set::__construct | public | function | Constructs a set object of the specified type, optionally with the specified data. |
Overrides AbstractArray::__construct | |
TypeTrait::checkType | protected | function | Returns `true` if value is of the specified type. | ||
ValueExtractorTrait::extractValue | protected | function | Extracts the value of the given property, method, or array key from the element. |
||
ValueToStringTrait::toolValueToString | protected | function | Returns a string representation of the value. |