HashMapObject abstraction
package | Default |
---|
__construct(array $data = null)
array
A value that will be used to initialize the HashMapObject. It can be an associative array (where each key/value will be directly assigned to the HashMap), or a plain array in which case the keys will be copied from each element numeric index
get(string $key): mixed
Throws |
|
---|
string
The key we are looking for
mixed
The value that is associated to the provided key
getAt(integer $index): mixed
Throws |
|
---|
integer
The position we are looking for
mixed
The value that is located at the specified position
getKeys(): array
array
List of strings containing all the HashMapObject sorted keys.
getValues(): array
array
List of elements containing all the HashMapObject sorted values
isKey(mixed $key): boolean
mixed
A value to find on the currently stored keys.
boolean
True if the provided value is a valid HashMap key, false in any other case
length(): integer
integer
The number of items inside the collection
pop(): mixed
Throws |
|
---|
mixed
The value on the last element of the list
remove(string $key): mixed
Throws |
|
---|
string
The key for the key/value pair we want to delete
mixed
The value from the key/value pair that's been deleted.
rename(string $key,string $newKey): boolean
Throws |
|
---|
string
The name we want to change
string
The new name that will replace the previous one
boolean
True if rename was successful
reverse(): void
set(string $key,mixed $value): mixed
If the key already exists, value will be replaced.
Throws |
|
---|
string
A string that labels the provided value
mixed
A value to be stored with the provided key
mixed
The value after being stored to the collection
shift(): mixed
Throws |
|
---|
mixed
The value on the first element of the list
sortByKey(string $method = self::SORT_METHOD_STRING,string $order = self::SORT_ORDER_ASCENDING): boolean
Throws |
|
---|
string
Defines sort mode: HashMapObject::SORT_STRING or HashMapObject::SORT_NUMERIC
string
Defines the order for the sorted elements: self::SORT_ORDER_ASCENDING (default) or self::SORT_ORDER_DESCENDING
boolean
True if sort was successful false on failure
swap(string $key1,string $key2): boolean
Throws |
|
---|
string
The first key to exchange
string
The second key to exchange
boolean
True if the two key/value pairs positions were correctly exchanged
SORT_METHOD_STRING
SORT_METHOD_NUMERIC
SORT_ORDER_ASCENDING
SORT_ORDER_DESCENDING