scalikephp

MutableMap extends ArrayMap Uses ArraySupport, MutableMapOps

A Mutable Map Implementation.

Table of Contents

__construct()  : mixed
Constructor.
append()  : static
Returns a new map containing the elements of this map followed by the given pair(s).
contains()  : bool
Tests whether this map contains a binding for a key.
count()  : int
create()  : Map
Create an instance from generator function.
drop()  : Map
each()  : void
Apply `$f` to each element for its side effects.
empty()  : Map
Get an empty Map instance.
emptyMap()  : Map
Get an empty Map instance.
exists()  : bool
Tests whether a predicate holds for at least one element of this collection.
filter()  : self
filterNot()  : static
Selects all elements of this collection which do not satisfy a predicate.
find()  : Option
Finds the first element of this collection satisfying a predicate, if any.
flatMap()  : self
flatten()  : Map
fold()  : mixed
forAll()  : bool
Tests whether a predicate holds for all elements of this collection.
from()  : Map
Create a Map instance from an iterable.
fromTraversable()  : Map
Create an instance from an iterator.
generate()  : Generator
Creates a new {@link Generator} from this collection.
get()  : Option
Optionally returns the value associated with a key.
getIterator()  : Traversable
getOrElse()  : mixed
Returns the value associated with a key, or a default value if the key is not contained in the map.
getOrElseUpdate()  : mixed
Returns associated value if given key is already in this map. Otherwise, computes value from given expression op, stores with key in map and returns that value.
groupBy()  : Map
head()  : mixed
Selects the first element of this collection.
headOption()  : Option
Optionally selects the first element.
isEmpty()  : bool
jsonSerialize()  : array<string|int, mixed>
keys()  : Seq
Collects all keys of this map in a seq.
last()  : mixed
Selects the last element of this collection.
lastOption()  : Option
Optionally selects the last element.
map()  : self
mapValues()  : self
max()  : array<string|int, mixed>
maxBy()  : array<string|int, mixed>
min()  : array<string|int, mixed>
minBy()  : array<string|int, mixed>
mkString()  : string
Returns all elements of this collection in a string using a separator string.
nonEmpty()  : bool
Tests whether this collection is not empty.
offsetExists()  : bool
PHP magic method: offsetExists.
offsetGet()  : mixed
PHP magic method: offsetGet.
offsetSet()  : void
PHP magic method: offsetSet.
offsetUnset()  : void
PHP magic method: offsetUnset.
partition()  : array<string|int, mixed>|array<string|int, Map>
remove()  : Option
Removes a key from this map, returning the value associated previously with that key as an Option.
size()  : int
sum()  : float|int
Sums up the elements of this collection.
sumBy()  : mixed
tail()  : static
Returns rest of this collection without its first element.
take()  : Map
takeRight()  : Map
toArray()  : array<string|int, mixed>
toAssoc()  : array<string|int, mixed>
Converts this collection to an assoc.
toGenerator()  : Generator
toSeq()  : Seq
update()  : void
Adds a new key/value pair to this map.
values()  : Seq
Collects all values of this map in a seq.

Methods

__construct()

Constructor.

public __construct(iteratable<string|int, mixed> $iterable) : mixed

The constructor of MutableMap.

Parameters
$iterable : iteratable<string|int, mixed>

Return values
mixed

append()

Returns a new map containing the elements of this map followed by the given pair(s).

public append(mixed $keyOrArray[, mixed $value = null ]) : static
Parameters
$keyOrArray : mixed
$value : mixed = null
Return values
static

contains()

Tests whether this map contains a binding for a key.

public abstract contains(int|string $key) : bool
Parameters
$key : int|string
Return values
bool

create()

Create an instance from generator function.

public final static create(Closure $f) : Map
Parameters
$f : Closure
Return values
Map

drop()

public drop(int $n) : Map
Parameters
$n : int
Return values
Map

each()

Apply `$f` to each element for its side effects.

public each(Closure $f) : void
Parameters
$f : Closure

the function to apply to each element.

Return values
void

empty()

Get an empty Map instance.

public final static empty() : Map
Return values
Map

emptyMap()

Get an empty Map instance.

public static emptyMap() : Map
Tags
deprecated

Use Map::empty() instead.

Return values
Map

exists()

Tests whether a predicate holds for at least one element of this collection.

public exists(Closure $p) : bool
Parameters
$p : Closure

the predicate used to test elements.

Return values
bool

true if the given predicate $p is satisfied by at least one element of this collection, otherwise false.

filter()

public filter(Closure $p) : self
Parameters
$p : Closure
Return values
self

filterNot()

Selects all elements of this collection which do not satisfy a predicate.

public filterNot(Closure $p) : static
Parameters
$p : Closure

the predicate used to test elements.

Return values
static

a new collection consisting of all elements of this collection that satisfy the given predicate $p.

find()

Finds the first element of this collection satisfying a predicate, if any.

public find(Closure $p) : Option
Parameters
$p : Closure

the predicate used to test elements.

Return values
Option

an Option containing the first element in this collection that satisfies $p, or None if none exists.

flatMap()

public flatMap(Closure $f) : self
Parameters
$f : Closure
Return values
self

fold()

public fold(mixed $z, Closure $op) : mixed
Parameters
$z : mixed
$op : Closure
Return values
mixed

forAll()

Tests whether a predicate holds for all elements of this collection.

public forAll(Closure $p) : bool
Parameters
$p : Closure

the predicate used to test elements.

Return values
bool

true if this collection is empty or the given predicate p holds for all elements of this collection, otherwise false.

from()

Create a Map instance from an iterable.

public final static from(null|iteratable<string|int, mixed> $iterable) : Map
Parameters
$iterable : null|iteratable<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
Map

fromTraversable()

Create an instance from an iterator.

public final static fromTraversable(Traversable $traversable) : Map
Parameters
$traversable : Traversable
Return values
Map

generate()

Creates a new {@link Generator} from this collection.

public generate(Closure $f) : Generator
Parameters
$f : Closure

the function to apply to each element. it should returns a .

Return values
Generator

get()

Optionally returns the value associated with a key.

public abstract get(int|string $key) : Option
Parameters
$key : int|string

the key value.

Return values
Option

an Option containing the value associated with key in this map, or None if none exists.

getIterator()

public getIterator() : Traversable
Return values
Traversable

getOrElse()

Returns the value associated with a key, or a default value if the key is not contained in the map.

public abstract getOrElse(int|string $key, Closure $default) : mixed
Parameters
$key : int|string

the key value.

$default : Closure

a closure that returns a default value in case no binding for key is found in the map.

Return values
mixed

the value associated with key if it exists, otherwise the result of the default computation.

getOrElseUpdate()

Returns associated value if given key is already in this map. Otherwise, computes value from given expression op, stores with key in map and returns that value.

public getOrElseUpdate(int|string $key, Closure $op) : mixed
Parameters
$key : int|string

the key to test.

$op : Closure

a closure returns the value to associate with key, if key is previously unbound.

Return values
mixed

the value associated with key (either previously or as a result of executing the method).

groupBy()

public groupBy(mixed $f) : Map
Parameters
$f : mixed
Return values
Map

head()

Selects the first element of this collection.

public head() : mixed
Return values
mixed

the first element of this collection.

headOption()

Optionally selects the first element.

public headOption() : Option
Return values
Option

the first element of this collection if it is non-empty, None if it is empty.

isEmpty()

public isEmpty() : bool
Return values
bool

jsonSerialize()

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

keys()

Collects all keys of this map in a seq.

public abstract keys() : Seq
Return values
Seq

the keys of this map as a seq.

last()

Selects the last element of this collection.

public last() : mixed
Return values
mixed

the last element of this collection.

lastOption()

Optionally selects the last element.

public lastOption() : Option
Return values
Option

the last element of this collection if it is non-empty, None if it is empty.

map()

public map(Closure $f) : self
Parameters
$f : Closure
Return values
self

mapValues()

public mapValues(Closure $f) : self
Parameters
$f : Closure
Return values
self

max()

public max() : array<string|int, mixed>
Return values
array<string|int, mixed>

maxBy()

public maxBy(Closure $f) : array<string|int, mixed>
Parameters
$f : Closure
Return values
array<string|int, mixed>

min()

public min() : array<string|int, mixed>
Return values
array<string|int, mixed>

minBy()

public minBy(Closure $f) : array<string|int, mixed>
Parameters
$f : Closure
Return values
array<string|int, mixed>

mkString()

Returns all elements of this collection in a string using a separator string.

public mkString([string $sep = '' ]) : string
Parameters
$sep : string = ''

the separator string.

Return values
string

a string representation of this collection. In the resulting string the string representations (w.r.t. the method __toString) of all elements of this collection are separated by the string sep.

nonEmpty()

Tests whether this collection is not empty.

public nonEmpty() : bool
Return values
bool

true if this collection does not contain any elements, false otherwise.

offsetExists()

PHP magic method: offsetExists.

public offsetExists( $offset) : bool
Parameters
$offset :
Return values
bool

offsetGet()

PHP magic method: offsetGet.

public offsetGet( $offset) : mixed
Parameters
$offset :
Return values
mixed

offsetSet()

PHP magic method: offsetSet.

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Return values
void

offsetUnset()

PHP magic method: offsetUnset.

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Return values
void

partition()

public partition(Closure $p) : array<string|int, mixed>|array<string|int, Map>
Parameters
$p : Closure
Return values
array<string|int, mixed>|array<string|int, Map>

remove()

Removes a key from this map, returning the value associated previously with that key as an Option.

public remove(int|string $key) : Option
Parameters
$key : int|string

the key to be removed.

Return values
Option

an Option value containing the value associated previously with key, or None if key was not defined in the map before.

sum()

Sums up the elements of this collection.

public sum() : float|int
Return values
float|int

the sum of all elements of this collection.

sumBy()

public sumBy(Closure $f) : mixed
Parameters
$f : Closure
Return values
mixed

tail()

Returns rest of this collection without its first element.

public tail() : static
Return values
static

take()

public take(int $n) : Map
Parameters
$n : int
Return values
Map

takeRight()

public takeRight(int $n) : Map
Parameters
$n : int
Return values
Map

toArray()

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

toAssoc()

Converts this collection to an assoc.

public abstract toAssoc() : array<string|int, mixed>
Return values
array<string|int, mixed>

toGenerator()

public toGenerator() : Generator
Return values
Generator

update()

Adds a new key/value pair to this map.

public update(int|string $key, mixed $value) : void

If the map already contains a mapping for the key, it will be overridden by the new value.

Parameters
$key : int|string

the key to update.

$value : mixed

the new value.

Return values
void

values()

Collects all values of this map in a seq.

public abstract values() : Seq
Return values
Seq

the values of this map as a seq.

Search results