Esempio n. 1
0
 /**
  * This method tests the "iterator" method.
  *
  * @dataProvider data_iterator
  */
 public function test_iterator(array $provided, array $expected)
 {
     $p0 = IArrayList\Type::make($provided[0], '\\Saber\\Data\\IInt32\\Type');
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Type', $p0);
     $this->assertCount(count($e0), $p0->unbox());
     $p1 = IArrayList\Module::iterator($p0);
     $e1 = 0;
     $this->assertInstanceOf('\\Saber\\Data\\IArrayList\\Iterator', $p1);
     foreach ($p1 as $i => $item) {
         $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $i);
         $this->assertSame($e1, $i->unbox());
         $this->assertInstanceOf('\\Saber\\Core\\Type', $item);
         $this->assertSame($e0[$e1], $item->unbox());
         $e1++;
     }
 }
Esempio n. 2
0
 /**
  * This method returns an iterator for this collection.
  *
  * @access public
  * @final
  * @return IArrayList\Iterator                              an iterator for this collection
  */
 public final function iterator() : IArrayList\Iterator
 {
     return IArrayList\Module::iterator($this->toArrayList());
 }
Esempio n. 3
0
 /**
  * This method returns a tuple of two (or more) array lists after splitting an array list of
  * tuple groupings.
  *
  * @access public
  * @static
  * @param IArrayList\Type $xss                              an array list of tuple groupings
  * @return ITuple\Type                                      a tuple of two (or more) array lists
  */
 public static function unzip(IArrayList\Type $xss) : ITuple\Type
 {
     $as = array();
     $bs = array();
     $xsi = IArrayList\Module::iterator($xss);
     foreach ($xsi as $i => $xs) {
         $as[] = $xs->first();
         $bs[] = $xs->second();
     }
     return ITuple\Type::box2(IArrayList\Type::box($as), IArrayList\Type::box($bs));
 }