PHP Interface Collections\DictionaryInterface

Inheritance: extends IteratorAggregate, extends Countable
显示文件 Open project: danielgsims/php-collections

Public Methods

Method Description
add ( $key, $value ) : static Adds the key-value pair containing $key and $value to the dictionary.
clear ( ) : static Removes every key-value pair from the dictionary.
count ( ) : integer Returns the number of key-value pairs in the dictionary.
delete ( $key ) : static Removes the key-value pair represented by $key from the dictionary.
each ( callable $callable ) Applies the callback function $callable to each key-value pair in the dictionary.
exists ( $key ) : boolean Returns true if $key is in the dictionary, returns false if it is not.
filter ( callable $condition ) : static Returns a dictionary that only contains the key-value pairs which satisfy $condition.
get ( $key ) : mixed Returns the value associated with $key.
getKeyType ( ) : string Returns the type of the dictionary's keys.
getOrElse ( $key, $default ) : mixed Returns the value associated with $key in the dictionary, returns $default if it does not.
getValueType ( ) : string Returns the type of the dictionary's values.
keys ( ) : array Returns an array of all keys in the dictionary.
map ( callable $callable ) : static Returns a new dictionary with the callback function $callable applied to every key-value pair in the dictionary.
merge ( $newItems ) : static Adds every key-value pair in $newItems to the dictionary.
toArray ( ) : array Returns the key-value pairs in the dictionary as an associative array.
valueExists ( $value ) : boolean Returns true if $value is in the dictionary, returns false if not.
values ( ) : array Returns an array of all values in the dictionary.
without ( callable $condition ) : static Removes all key-value pairs from the Dictionary that do not satisfy $condition.

Method Details

add() public method

Adds the key-value pair containing $key and $value to the dictionary.
public add ( $key, $value ) : static
$key
$value
return static

clear() public method

Removes every key-value pair from the dictionary.
public clear ( ) : static
return static

count() public method

Returns the number of key-value pairs in the dictionary.
public count ( ) : integer
return integer

delete() public method

Removes the key-value pair represented by $key from the dictionary.
public delete ( $key ) : static
$key
return static

each() public method

Applies the callback function $callable to each key-value pair in the dictionary.
public each ( callable $callable )
$callable callable

exists() public method

Returns true if $key is in the dictionary, returns false if it is not.
public exists ( $key ) : boolean
$key
return boolean

filter() public method

Returns a dictionary that only contains the key-value pairs which satisfy $condition.
public filter ( callable $condition ) : static
$condition callable
return static

get() public method

Returns the value associated with $key.
public get ( $key ) : mixed
$key
return mixed

getKeyType() public method

Returns the type of the dictionary's keys.
public getKeyType ( ) : string
return string

getOrElse() public method

Returns the value associated with $key in the dictionary, returns $default if it does not.
public getOrElse ( $key, $default ) : mixed
$key
$default
return mixed

getValueType() public method

Returns the type of the dictionary's values.
public getValueType ( ) : string
return string

keys() public method

Returns an array of all keys in the dictionary.
public keys ( ) : array
return array

map() public method

Returns a new dictionary with the callback function $callable applied to every key-value pair in the dictionary.
public map ( callable $callable ) : static
$callable callable
return static

merge() public method

Adds every key-value pair in $newItems to the dictionary.
public merge ( $newItems ) : static
$newItems
return static

toArray() public method

Returns the key-value pairs in the dictionary as an associative array.
public toArray ( ) : array
return array

valueExists() public method

Returns true if $value is in the dictionary, returns false if not.
public valueExists ( $value ) : boolean
$value
return boolean

values() public method

Returns an array of all values in the dictionary.
public values ( ) : array
return array

without() public method

Removes all key-value pairs from the Dictionary that do not satisfy $condition.
public without ( callable $condition ) : static
$condition callable
return static