예제 #1
0
 /**
  * This method returns an object with a "0" value.
  *
  * @access public
  * @static
  * @return ITrit\Type                                       the object
  */
 public static function zero() : ITrit\Type
 {
     return ITrit\Type::box(0);
 }
예제 #2
0
 /**
  * This method tests the "covariant" method.
  *
  * @dataProvider data_covariant
  */
 public function test_covariant(array $provided, array $expected)
 {
     $p0 = ITrit\Type::covariant(ITrit\Type::box($provided[0]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\ITrit\\Type', $p0);
     $this->assertSame($e0, $p0->unbox());
 }
예제 #3
0
 /**
  * This method compares the operands for order.
  *
  * @access public
  * @static
  * @param IInt32\Type $x                                    the left operand
  * @param IInt32\Type $y                                    the right operand
  * @return ITrit\Type                                       the order as to whether the left
  *                                                          operand is less than, equals to,
  *                                                          or greater than the right operand
  */
 public static function compare(IInt32\Type $x, IInt32\Type $y) : ITrit\Type
 {
     return ITrit\Type::box($x->unbox() <=> $y->unbox());
 }
예제 #4
0
 /**
  * This method compares the operands for order.
  *
  * @access public
  * @static
  * @param ITuple\Type $xs                                   the left operand
  * @param ITuple\Type $ys                                   the right operand
  * @return ITrit\Type                                       the order as to whether the left
  *                                                          operand is less than, equals to,
  *                                                          or greater than the right operand
  */
 public static function compare(ITuple\Type $xs, ITuple\Type $ys) : ITrit\Type
 {
     $xsl = $xs->length();
     $ysl = $ys->length();
     $length = IInt32\Module::min($xsl, $ysl);
     for ($i = IInt32\Type::zero(); IInt32\Module::lt($i, $length)->unbox(); $i = IInt32\Module::increment($i)) {
         $r = $xs->item($i)->compare($ys->item($i));
         if ($r->unbox() != 0) {
             return $r;
         }
     }
     return ITrit\Type::box($xsl->unbox() <=> $ysl->unbox());
 }
예제 #5
0
 /**
  * This method compares the operands for order.
  *
  * @access public
  * @static
  * @param IChar\Type $x                                     the left operand
  * @param IChar\Type $y                                     the right operand
  * @return ITrit\Type                                       the order as to whether the left
  *                                                          operand is less than, equals to,
  *                                                          or greater than the right operand
  */
 public static function compare(IChar\Type $x, IChar\Type $y) : ITrit\Type
 {
     return ITrit\Type::box(ord($x->unbox()) <=> ord($y->unbox()));
 }
예제 #6
0
 /**
  * This method compares the operands for order.
  *
  * @access public
  * @static
  * @param ILinkedList\Type $xs                              the left operand
  * @param ILinkedList\Type $ys                              the right operand
  * @return ITrit\Type                                       the order as to whether the left
  *                                                          operand is less than, equals to,
  *                                                          or greater than the right operand
  */
 public static function compare(ILinkedList\Type $xs, ILinkedList\Type $ys) : ITrit\Type
 {
     for ($as = $xs, $bs = $ys; !$as->__isEmpty() && !$bs->__isEmpty(); $as = $as->tail(), $bs = $bs->tail()) {
         $r = $as->head()->compare($bs->head());
         if ($r->unbox() != 0) {
             return $r;
         }
     }
     return ITrit\Type::box($xs->__length() <=> $ys->__length());
 }