HashMapObject

HashMapObject abstraction

package

Default

Methods

An Object that defines a sorted collection of key/value pairs and all their related operations.

__construct(array $data = null)
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$data

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 the value that is associated to a key from an existing key/value pair

get(string $key): mixed
Throws
\InvalidArgumentException

If key does not exist or is invalid

Arguments

$key

string

The key we are looking for

Response

mixed

The value that is associated to the provided key

Get the value that is located at a certain position at the ordered list of key/pair values

getAt(integer $index): mixed
Throws
\InvalidArgumentException

If index does not exist or is invalid

Arguments

$index

integer

The position we are looking for

Response

mixed

The value that is located at the specified position

Get a list with all the keys from the HashMapObject with the same order as they are stored.

getKeys(): array
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Response

array

List of strings containing all the HashMapObject sorted keys.

Get a list with all the values from the HashMapObject with the same order as they are stored.

getValues(): array
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Response

array

List of elements containing all the HashMapObject sorted values

Tells if the provided value matches a key that's stored inside the HashMapObject

isKey(mixed $key): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$key

mixed

A value to find on the currently stored keys.

Response

boolean

True if the provided value is a valid HashMap key, false in any other case

Get the number of key/value pairs that are currently stored on this HashMapObject instance

length(): integer
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Response

integer

The number of items inside the collection

Remove and get the last element value from the HashMapObject sorted list

pop(): mixed
Throws
\UnexpectedValueException

If the HashMapObject is empty

Response

mixed

The value on the last element of the list

Delete a key/value pair from the HashMapObject, given it's key.

remove(string $key): mixed
Throws
\InvalidArgumentException

Arguments

$key

string

The key for the key/value pair we want to delete

Response

mixed

The value from the key/value pair that's been deleted.

Change the name for an existing key

rename(string $key,string $newKey): boolean
Throws
\InvalidArgumentException

Arguments

$key

string

The name we want to change

$newKey

string

The new name that will replace the previous one

Response

boolean

True if rename was successful

Reverse the order of the HashMapObject elements

reverse(): void
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Backups/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Define a key / value pair and add it to the collection.

set(string $key,mixed $value): mixed

If the key already exists, value will be replaced.

Throws
\InvalidArgumentException

If invalid key is provided

Arguments

$key

string

A string that labels the provided value

$value

mixed

A value to be stored with the provided key

Response

mixed

The value after being stored to the collection

Remove and get the first element value from the HashMapObject sorted list

shift(): mixed
Throws
\UnexpectedValueException

If the HashMapObject is empty

Response

mixed

The value on the first element of the list

Sort the key/value pairs inside the HashMapObject by their key values.

sortByKey(string $method = self::SORT_METHOD_STRING,string $order = self::SORT_ORDER_ASCENDING): boolean
Throws
\InvalidArgumentException

Arguments

$method

string

Defines sort mode: HashMapObject::SORT_STRING or HashMapObject::SORT_NUMERIC

$order

string

Defines the order for the sorted elements: self::SORT_ORDER_ASCENDING (default) or self::SORT_ORDER_DESCENDING

Response

boolean

True if sort was successful false on failure

Exchange the positions for two key/value pairs on the HashMapObject sorted elements list

swap(string $key1,string $key2): boolean
Throws
\InvalidArgumentException

If any of the two provided keys does not exist or is invalid

Arguments

$key1

string

The first key to exchange

$key2

string

The second key to exchange

Response

boolean

True if the two key/value pairs positions were correctly exchanged

Constants

Sort mode that compares values as strings (alphabetically)

SORT_METHOD_STRING

Sort mode that compares values as numbers (Avoid using it with non numeric values)

SORT_METHOD_NUMERIC

Defines that elements will be sorted upward

SORT_ORDER_ASCENDING

Defines that elements will be sorted downward

SORT_ORDER_DESCENDING