/** * */ public function testPopMethodOnMapping() { $map = new HashMap(); $map['foo'] = 'bar'; $this->assertEquals('bar', $map->pop('foo')); $this->assertCount(0, $map); $this->assertEquals('default', $map->pop('any', 'default')); }
/** * */ public function update($iterable) { if ($iterable !== null) { if ($iterable instanceof Mapping) { if (count($this) > 0) { foreach ($iterable->items() as list($elem, $count)) { $this[$elem] = $count + $this->get($elem, 0); } } else { parent::update($iterable); } } else { foreach ($iterable as $elem) { $this[$elem] = $this->get($elem, 0) + 1; } } } }
/** * */ public function __construct(callable $factory = null, $initial = null) { $this->factory = $factory; parent::__construct($initial); }