예제 #1
0
 /**
  * This method tests the "box" method.
  *
  * @dataProvider data_box
  */
 public function test_box(array $provided, array $expected)
 {
     $p0 = ILinkedList\Type::box(array_map(function ($item) {
         return IObject\Type::box($item);
     }, $provided[0]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\ILinkedList\\Type', $p0);
     $this->assertSame($e0, $p0->unbox(1));
 }
예제 #2
0
 /**
  * This method returns a value as a boxed object.  A value is typically a PHP typed
  * primitive or object.  It is considered "not" type-safe.
  *
  * @access public
  * @static
  * @param mixed ...$xs                                      the value(s) to be boxed
  * @return ILinkedList\Type                                 the boxed object
  */
 public static function box2(...$xs) : ILinkedList\Type
 {
     return ILinkedList\Type::box($xs);
 }
예제 #3
0
 /**
  * This method returns a tuple of two (or more) linked lists after splitting a linked list of
  * tuple groupings.
  *
  * @access public
  * @static
  * @param ILinkedList\Type $xss                             a linked list of tuple groupings
  * @return ITuple\Type                                      a tuple of two (or more) linked lists
  */
 public static function unzip(ILinkedList\Type $xss) : ITuple\Type
 {
     $as = array();
     $bs = array();
     $xsi = ILinkedList\Module::iterator($xss);
     foreach ($xsi as $i => $xs) {
         $as[] = $xs->first();
         $bs[] = $xs->second();
     }
     return ITuple\Type::box2(ILinkedList\Type::box($as), ILinkedList\Type::box($bs));
 }