Map extends ScalikeTraversable Uses MapBuilder
Scala like Map.
Table of Contents
- 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.
- create() : Map
- Create an instance from generator function.
- 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.
- 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.
- 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.
- getOrElse() : mixed
- Returns the value associated with a key, or a default value if the key is not contained in the map.
- head() : mixed
- Selects the first element of this collection.
- headOption() : Option
- Optionally selects the first element.
- 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.
- mapValues() : Map
- Transforms this map by applying a function to every retrieved value.
- mkString() : string
- Returns all elements of this collection in a string using a separator string.
- nonEmpty() : bool
- Tests whether this collection is not empty.
- offsetSet() : void
- PHP magic method: offsetSet.
- offsetUnset() : void
- PHP magic method: offsetUnset.
- sum() : float|int
- Sums up the elements of this collection.
- tail() : static
- Returns rest of this collection without its first element.
- toAssoc() : array<string|int, mixed>
- Converts this collection to an assoc.
- values() : Seq
- Collects all values of this map in a seq.
Methods
append()
Returns a new map containing the elements of this map followed by the given pair(s).
public
abstract append(array<string|int, mixed>|Map|string $keyOrArray[, mixed $value = null ]) : static
Parameters
- $keyOrArray : array<string|int, mixed>|Map|string
- $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 —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
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.
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.
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
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
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.
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.
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.
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.
mapValues()
Transforms this map by applying a function to every retrieved value.
public
abstract mapValues(Closure $f) : Map
Parameters
- $f : Closure
-
the function used to transform values of this map.
Return values
Map —a map which maps every key of this map to $f($this[$key])
.
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.
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 —sum()
Sums up the elements of this collection.
public
sum() : float|int
Return values
float|int —the sum of all elements of this collection.
tail()
Returns rest of this collection without its first element.
public
tail() : static
Return values
static —toAssoc()
Converts this collection to an assoc.
public
abstract toAssoc() : array<string|int, mixed>
Return values
array<string|int, mixed> —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.