$keyType
$keyType : string
The class name of the key.
A specialized map implementation for use with enum type keys.
All of the keys in an enum map must come from a single enum type that is specified, when the map is created. Enum maps are represented internally as arrays. This representation is extremely compact and efficient.
Enum maps are maintained in the natural order of their keys (the order in which the enum constants are declared). This is reflected in the iterators returned by the collection views {@see \DASPRiD\Enum\self::getIterator()} and {@see \DASPRiD\Enum\self::values()}.
Iterators returned by the collection views are not consistent: They may or may not show the effects of modifications to the map that occur while the iteration is in progress.
$keyType : string
The class name of the key.
$valueType : string
The type of the value.
$allowNullValues : bool
$keyUniverse : array<int,\DASPRiD\Enum\AbstractEnum>
All of the constants comprising the enum, cached for performance.
$values : array<int,mixed>
Array representation of this map. The ith element is the value to which universe[i] is currently mapped, or null if it isn't mapped to anything, or NullValue if it's mapped to null.
$size : int
__construct(string $keyType, string $valueType, bool $allowNullValues) : mixed
Creates a new enum map.
string | $keyType | the type of the keys, must extend AbstractEnum |
string | $valueType | the type of the values |
bool | $allowNullValues | whether to allow null values |
when key type does not extend AbstractEnum
expect(string $keyType, string $valueType, bool $allowNullValues) : void
Checks whether the map types match the supplied ones.
You should call this method when an EnumMap is passed to you and you want to ensure that it's made up of the correct types.
string | $keyType | |
string | $valueType | |
bool | $allowNullValues |
when supplied key type mismatches local key type
when supplied value type mismatches local value type
when the supplied map allows null values, abut should not
get(\DASPRiD\Enum\AbstractEnum $key) : mixed
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key to a value, then this method returns the value; otherwise it returns null (there can be at most one such mapping).
A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that hte map explicitly maps the key to null. The {@see \DASPRiD\Enum\self::containsKey()} operation may be used to distinguish these two cases.
\DASPRiD\Enum\AbstractEnum | $key |
put(\DASPRiD\Enum\AbstractEnum $key, mixed $value) : mixed
Associates the specified value with the specified key in this map.
If the map previously contained a mapping for this key, the old value is replaced.
\DASPRiD\Enum\AbstractEnum | $key | |
mixed | $value |
when the passed values does not match the internal value type
the previous value associated with the specified key, or null if there was no mapping for the key. (a null return can also indicate that the map previously associated null with the specified key.)
remove(\DASPRiD\Enum\AbstractEnum $key) : mixed
Removes the mapping for this key frm this map if present.
\DASPRiD\Enum\AbstractEnum | $key |
the previous value associated with the specified key, or null if there was no mapping for the key. (a null return can also indicate that the map previously associated null with the specified key.)