Example #1
0
 /**
  *
  */
 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'));
 }
Example #2
0
 /**
  *
  */
 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;
             }
         }
     }
 }
Example #3
0
 /**
  *
  */
 public function __construct(callable $factory = null, $initial = null)
 {
     $this->factory = $factory;
     parent::__construct($initial);
 }