Exemple #1
0
 /**
  * This method unsubscribes a listener.
  *
  * @access public
  * @static
  * @param IHashMap\Type $xs                                 the left operand
  * @param ITuple\Type $entry                                a tuple containing the key and listener
  * @return IHashMap\Type                                    the map
  */
 public static function unsubscribe(IHashMap\Type $xs, ITuple\Type $entry) : IHashMap\Type
 {
     $k = $entry->first();
     if ($xs->__hasKey($k)) {
         $ys = ILinkedList\Module::delete($xs->item($k), $entry->second());
         $zs = IHashMap\Module::putEntry($xs, ITuple\Type::box2($k, $ys));
         return $zs;
     }
     return $xs;
 }
 /**
  * This method tests the "or" method.
  *
  * @dataProvider data_or
  */
 public function test_or(array $provided, array $expected)
 {
     $p0 = ILinkedList\Type::make($provided[0], '\\Saber\\Data\\IBool\\Type');
     $r0 = ILinkedList\Module::or_($p0);
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $r0);
     $this->assertSame($e0, $r0->unbox());
 }
 /**
  * This method tests the "toLinkedList" method.
  *
  * @dataProvider data_toLinkedList
  */
 public function test_toLinkedList(array $provided, array $expected)
 {
     $p0 = ILinkedList\Module::toLinkedList(ILinkedList\Type::make($provided[0], '\\Saber\\Data\\IInt32\\Type'));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\ILinkedList\\Type', $p0);
     $this->assertSame($e0, $p0->unbox(1));
 }
Exemple #4
0
 /**
  * This method returns the collection as a linked list.
  *
  * @access public
  * @static
  * @param IArrayList\Type $xs                               the operand
  * @return ILinkedList\Type                                 the collection as a linked list
  */
 public static function toLinkedList(IArrayList\Type $xs) : ILinkedList\Type
 {
     return IArrayList\Module::foldLeft($xs, function (ILinkedList\Type $c, Core\Type $x) {
         return ILinkedList\Module::append($c, $x);
     }, ILinkedList\Type::empty_());
 }
Exemple #5
0
 /**
  * This method returns whether any of the items of the list evaluate to true.
  *
  * @access public
  * @static
  * @param ILinkedList\Type $xs                              the left operand
  * @return IBool\Type                                       whether all of the items of
  *                                                          the list evaluate to false
  */
 public static function or_(ILinkedList\Type $xs) : IBool\Type
 {
     return ILinkedList\Module::any($xs, function (IBool\Type $x, IInt32\Type $i) : IBool\Type {
         return $x;
     });
 }