33 lines
603 B
Markdown
33 lines
603 B
Markdown
|
# olivebbs/map
|
||
|
|
||
|
Very simple typed map class.
|
||
|
|
||
|
Includes IntCharMap and CharMap as examples. It is best to extend `Olivebbs\Map\GenericMap `for your uses.
|
||
|
|
||
|
### Example
|
||
|
|
||
|
```php
|
||
|
use Olivebbs\Map\GenericMap;
|
||
|
|
||
|
final class MyStringMap extends GenericMap
|
||
|
{
|
||
|
public function __construct(array $values)
|
||
|
{
|
||
|
parent::__construct(GenericMap::STRING, GenericMap::STRING);
|
||
|
$this->map->putAll($values);
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
or
|
||
|
|
||
|
```php
|
||
|
use Olivebbs\Map\GenericMap;
|
||
|
|
||
|
$myIntMap = new GenericMap(GenericMap::INT, GenericMap::INT);
|
||
|
```
|
||
|
Then use it.
|
||
|
```php
|
||
|
$myIntMap[0] = 500;
|
||
|
unset($myIntMap[0]) // null
|
||
|
```
|