2021-03-03 13:59:55 -08:00
|
|
|
# olivebbs/map
|
|
|
|
|
|
|
|
Very simple typed map class.
|
|
|
|
|
2022-05-11 16:28:23 -07:00
|
|
|
|
2021-03-03 13:59:55 -08:00
|
|
|
Includes IntCharMap and CharMap as examples. It is best to extend `Olivebbs\Map\GenericMap `for your uses.
|
|
|
|
|
|
|
|
### Example
|
|
|
|
|
|
|
|
```php
|
|
|
|
use Olivebbs\Map\GenericMap;
|
2022-05-11 16:28:23 -07:00
|
|
|
use Olivebbs\Map\Enum\ValueType;
|
|
|
|
use Olivebbs\Map\Enum\KeyType;
|
2021-03-03 13:59:55 -08:00
|
|
|
|
|
|
|
final class MyStringMap extends GenericMap
|
|
|
|
{
|
|
|
|
public function __construct(array $values)
|
|
|
|
{
|
2022-05-11 16:28:23 -07:00
|
|
|
parent::__construct(KeyType::STRING, ValueType::STRING);
|
2021-03-03 13:59:55 -08:00
|
|
|
$this->map->putAll($values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
```php
|
|
|
|
use Olivebbs\Map\GenericMap;
|
2022-05-11 16:28:23 -07:00
|
|
|
use Olivebbs\Map\Enum\ValueType;
|
|
|
|
use Olivebbs\Map\Enum\KeyType;
|
2021-03-03 13:59:55 -08:00
|
|
|
|
2022-05-11 16:28:23 -07:00
|
|
|
$myIntMap = new GenericMap(KeyType::INT, ValueType::INT);
|
2021-03-03 13:59:55 -08:00
|
|
|
```
|
|
|
|
Then use it.
|
|
|
|
```php
|
|
|
|
$myIntMap[0] = 500;
|
|
|
|
unset($myIntMap[0]) // null
|
|
|
|
```
|