private function mapIterator(callable $function = null) { if ($function === null) { return $this->elements; } else { return $this->scheme->projectionIterator($this->elements, null, $function); } }
public function iterate(callable $function) { $this->scheme->walk($this->getTrueIterator(), $function); }
/** * @dataProvider orderedMaps */ public function testThatOffsetSetWithNoKeyAppendsWithNextLargestIntGreaterThanOrEqualToZero(IOrderedMap $orderedMap, IIteratorScheme $scheme) { $orderedMap = $scheme->createOrderedMap($scheme->arrayIterator([-5 => 'foo'])); $orderedMap[] = 'bar'; $orderedMap[7] = 'baz'; $orderedMap[] = 'qux'; $this->assertSame('foo', $orderedMap->get(-5)); $this->assertSame('bar', $orderedMap->get(0)); $this->assertSame('baz', $orderedMap->get(7)); $this->assertSame('qux', $orderedMap->get(8)); $orderedMap->remove(8); $this->assertFalse($orderedMap->contains(8)); $orderedMap[] = 'qux1'; $this->assertSame('qux1', $orderedMap->get(8)); $orderedMap->remove(8); $orderedMap->remove(7); $orderedMap[] = 'boo'; $this->assertSame('boo', $orderedMap->get(1)); }