final class Map implements Countable, IteratorAggregate, JsonSerializable, ArrayAccess (View source)

Constants

MIN_CAPACITY

Methods

__construct(iterable $values = [])

No description

void
allocate(int $capacity)

No description

void
apply(callable $callback)

No description

int
capacity()

No description

void
clear()

No description

Map
copy()

No description

int
count()

Count elements of an object

Map
diff(Map $map)

No description

Map
filter(callable|null $callback = null)

No description

first()

No description

TValue|null
get(TKey $key, TValue|null $default = null)

No description

getIterator()

No description

bool
hasKey(TKey $key)

No description

bool
hasValue(TValue $value)

No description

Map
intersect(Map $map)

No description

bool
isEmpty()

No description

mixed
jsonSerialize()

No description

Set
keys()

No description

void
ksort(callable|null $comparator = null)

No description

Map
ksorted(callable|null $comparator = null)

No description

last()

No description

Map
map(callable $callback)

No description

Map
merge(TValue> $values)

No description

Seq
pairs()

No description

void
put(TKey $key, TValue $value)

No description

void
putAll(TValue> $values)

No description

TReturn|null
reduce(callable $callback, TInitial|null $initial = null)

No description

TValue|null
remove(TKey $key, TValue|null $default = null)

No description

void
reverse()

No description

Map
reversed()

No description

skip(int $position)

No description

Map
slice(int $index, int|null $length = null)

No description

void
sort(callable|null $comparator = null)

No description

Map
sorted(callable|null $comparator = null)

No description

int|float
sum()

No description

array
toArray()

No description

Map
union(Map $map)

No description

Seq
values()

No description

Map
xor(Map $map)

No description

array
__serialize()

No description

void
__unserialize(array $data)

No description

bool
offsetExists(TKey $offset)

Whether a offset exists

mixed
offsetGet(TKey $offset)

Offset to retrieve

void
offsetSet(TKey $offset, TValue $value)

Offset to set

void
offsetUnset(TKey $offset)

Offset to unset

Details

__construct(iterable $values = [])

No description

Parameters

iterable $values

A traversable object or an array to use for the initial values.

void allocate(int $capacity)

No description

Parameters

int $capacity

Return Value

void

void apply(callable $callback)

No description

Parameters

callable $callback

callback ( mixed \$key , mixed \$value ): mixed
A callable to apply to each value in the map. The callback should return what the value should be replaced by.

Return Value

void

int capacity()

No description

Return Value

int

void clear()

No description

Return Value

void

Map copy()

No description

Return Value

Map

Returns a shallow copy of the map.

int count()

Count elements of an object

Return Value

int

The custom count as an integer.

The return value is cast to an integer.

Map diff(Map $map)

No description

Parameters

Map $map

Return Value

Map

The result of removing all keys from the current instance that are present in a given map.

Map filter(callable|null $callback = null)

No description

Parameters

callable|null $callback

callback ( mixed \$key , mixed \$value ): bool
Optional callable which returns true if the pair should be included, false otherwise. If a callback is not provided, only values which are true (see converting to boolean) will be included.

Return Value

Map

A new map containing all the pairs for which either the callback returned true, or all values that convert to true if a callback was not provided.

Pair first()

No description

Return Value

Pair

The first pair in the map.

TValue|null get(TKey $key, TValue|null $default = null)

No description

Parameters

TKey $key

The key to look up.

TValue|null $default

The optional default value, returned if the key could not be found.

Return Value

TValue|null

The value mapped to the given key, or the default value if provided and the key could not be found in the map.

Traversable getIterator()

No description

Return Value

Traversable

An instance of an object implementing Iterator or Traversable

bool hasKey(TKey $key)

No description

Parameters

TKey $key

The key to look for.

Return Value

bool

bool hasValue(TValue $value)

No description

Parameters

TValue $value

The value to look for.

Return Value

bool

Map intersect(Map $map)

No description

Parameters

Map $map

Return Value

Map

The key intersection of the current instance and another map.

bool isEmpty()

No description

Return Value

bool

mixed jsonSerialize()

No description

Return Value

mixed

data which can be serialized by json_encode, which is a value of any type other than a resource.

Set keys()

No description

Return Value

Set

A Ds\Set containing all the keys of the map.

void ksort(callable|null $comparator = null)

No description

Parameters

callable|null $comparator

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. Returning non-integer values from the comparison function, such as float, will result in an internal cast to int of the callback's return value. So values such as 0.99 and 0.1 will both be cast to an integer value of 0, which will compare such values as equal.

Return Value

void

Map ksorted(callable|null $comparator = null)

No description

Parameters

callable|null $comparator

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. Returning non-integer values from the comparison function, such as float, will result in an internal cast to int of the callback's return value. So values such as 0.99 and 0.1 will both be cast to an integer value of 0, which will compare such values as equal.

Return Value

Map

Returns a copy of the map, sorted by key.

Pair last()

No description

Return Value

Pair

The last pair of the map.

Map map(callable $callback)

No description

Parameters

callable $callback

callback ( mixed \$key , mixed \$value ): mixed
A callable to apply to each value in the map. The callable should return what the key will be mapped to in the resulting map.

Return Value

Map

The result of applying a callback to each value in the map. The keys and values of the current instance won't be affected.

Map merge(TValue> $values)

No description

Parameters

TValue> $values

A traversable object or an array.

Return Value

Map

The result of associating all keys of a given traversable object or array with their corresponding values, combined with the current instance. The current instance won't be affected.

Seq pairs()

No description

Return Value

Seq

Ds\Sequence containing all the pairs of the map.

void put(TKey $key, TValue $value)

No description

Parameters

TKey $key

The key to associate the value with.

TValue $value

The value to be associated with the key.

Return Value

void

void putAll(TValue> $values)

No description

Parameters

TValue> $values

Return Value

void

TReturn|null reduce(callable $callback, TInitial|null $initial = null)

No description

Parameters

callable $callback

callback ( mixed \$carry , mixed \$key , mixed \$value ): mixed
\$carry - The return value of the previous callback, or initial if it's the first iteration.
\$key - The key of the current iteration.
\$value - The value of the current iteration.

TInitial|null $initial

The initial value of the carry value. Can be null.

Return Value

TReturn|null

The return value of the final callback.

TValue|null remove(TKey $key, TValue|null $default = null)

No description

Parameters

TKey $key

The key to remove.

TValue|null $default

The optional default value, returned if the key could not be found.

Return Value

TValue|null

The value that was removed, or the default value if provided and the key could not be found in the map.

void reverse()

No description

Return Value

void

Map reversed()

No description

Return Value

Map

A reversed copy of the map. The current instance is not affected.

Pair skip(int $position)

No description

Parameters

int $position

Return Value

Pair

Returns the Ds\Pair at the given position.

Map slice(int $index, int|null $length = null)

No description

Parameters

int $index
int|null $length

Return Value

Map

A subset of the map defined by a starting index and length.

void sort(callable|null $comparator = null)

No description

Parameters

callable|null $comparator

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. Returning non-integer values from the comparison function, such as float, will result in an internal cast to int of the callback's return value. So values such as 0.99 and 0.1 will both be cast to an integer value of 0, which will compare such values as equal.

Return Value

void

Map sorted(callable|null $comparator = null)

No description

Parameters

callable|null $comparator

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. Returning non-integer values from the comparison function, such as float, will result in an internal cast to int of the callback's return value. So values such as 0.99 and 0.1 will both be cast to an integer value of 0, which will compare such values as equal.

Return Value

Map

Returns a copy of the map, sorted by value.

int|float sum()

No description

Return Value

int|float

The sum of all the values in the map as either a float or int depending on the values in the map.

array toArray()

No description

Return Value

array

An array containing all the values in the same order as the map.

Map union(Map $map)

No description

Parameters

Map $map

Return Value

Map

A new map containing all the pairs of the current instance as well as another map.

Seq values()

No description

Return Value

Seq

A Ds\Sequence containing all the values of the map.

Map xor(Map $map)

No description

Parameters

Map $map

Return Value

Map

A new map containing keys in the current instance as well as another map, but not in both.

array __serialize()

No description

Return Value

array

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void

bool offsetExists(TKey $offset)

Whether a offset exists

Parameters

TKey $offset

An offset to check for.

Return Value

bool

true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

mixed offsetGet(TKey $offset)

Offset to retrieve

Parameters

TKey $offset

The offset to retrieve.

Return Value

mixed

Can return all value types.

void offsetSet(TKey $offset, TValue $value)

Offset to set

Parameters

TKey $offset

The offset to assign the value to.

TValue $value

The value to set.

Return Value

void

No value is returned.

void offsetUnset(TKey $offset)

Offset to unset

Parameters

TKey $offset

The offset to unset.

Return Value

void

No value is returned.