scalikephp

TraversableMap extends Map Uses MapOps, TraversableSupport

A Map Implementation using \Traversable.

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()  : Map
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()  : Map
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.
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()  : Map
mapValues()  : Map
Transforms this map by applying a function to every retrieved value.
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>
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
values()  : Seq
Collects all values of this map in a seq.

Methods

__construct()

Constructor.

public __construct(Traversable $traversable) : mixed

The constructor of TraversableMap.

Parameters
$traversable : Traversable
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 contains(mixed $key) : bool
Parameters
$key : mixed
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
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) : Map
Parameters
$p : Closure
Return values
Map —

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) : Map
Parameters
$f : Closure
Return values
Map —

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 get(mixed $key) : Option
Parameters
$key : mixed

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.

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.

jsonSerialize()

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

keys()

Collects all keys of this map in a seq.

public 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) : Map
Parameters
$f : Closure
Return values
Map —

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]).

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> —

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 —

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 toAssoc() : array<string|int, mixed>
Return values
array<string|int, mixed> —

toGenerator()

public toGenerator() : Generator
Return values
Generator —

values()

Collects all values of this map in a seq.

public values() : Seq
Return values
Seq —

the values of this map as a seq.

Search results