createOrderedMap() public méthode

Keys can only be associated with a single value and such if the iterator returns duplicate keys the last respective value will be used.
public createOrderedMap ( Traversable $iterator = null ) : Pinq\Iterators\IOrderedMap
$iterator Traversable
Résultat Pinq\Iterators\IOrderedMap
Exemple #1
0
 /**
  * @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));
 }
Exemple #2
0
 /**
  * @return Iterators\IOrderedMap
  */
 protected function asOrderedMap()
 {
     return $this->elements instanceof Iterators\IOrderedMap ? $this->elements : $this->scheme->createOrderedMap($this->elements);
 }