Example #1
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param IObject\Type $x                                   the left operand
  * @param Core\Type $y                                      the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(IObject\Type $x, Core\Type $y) : IBool\Type
 {
     // ===
     if ($y !== null) {
         if ($x->__typeOf() === $y->__typeOf()) {
             return IBool\Type::box($x->unbox() === $y->unbox());
         }
     }
     return IBool\Type::false();
 }
Example #2
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param IUnit\Type $x                                     the left operand
  * @param Core\Type $y                                      the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(IUnit\Type $x, Core\Type $y) : IBool\Type
 {
     // ===
     $type = $x === null ? '\\Saber\\Data\\IUnit\\Type' : $x->__typeOf();
     return IBool\Type::box($y === null || $type === $y->__typeOf());
 }
Example #3
0
 /**
  * This method evaluates whether the specified object is identical to the current object.
  *
  * @access public
  * @static
  * @param IOption\Type $xs                                  the left operand
  * @param Core\Type $ys                                     the object to be evaluated
  * @return IBool\Type                                       whether the specified object is identical
  *                                                          to the current object
  */
 public static function id(IOption\Type $xs, Core\Type $ys) : IBool\Type
 {
     if ($ys !== null) {
         if ($xs->__typeOf() === $ys->__typeOf()) {
             if ($ys instanceof IOption\Some\Type) {
                 $x = $xs->item();
                 $y = $ys->item();
                 if ($x === null) {
                     return IBool\Type::box($y === null);
                 } else {
                     if ($x instanceof Core\Equality\Type) {
                         return $x->id($y);
                     }
                 }
                 return IBool\Type::box(spl_object_hash($x) === spl_object_hash($y));
             } else {
                 if ($ys instanceof IOption\None\Type) {
                     return IBool\Type::true();
                 }
             }
         }
     }
     return IBool\Type::false();
 }
Example #4
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param Throwable\Runtime\Exception $x                    the left operand
  * @param Core\Type $y                                      the right operand
  * @return IBool\Type                                        whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(Throwable\Runtime\Exception $x, Core\Type $y)
 {
     // ===
     if ($y !== null) {
         if ($x->__typeOf() === $y->__typeOf()) {
             return IBool\Type::box($x->__hashCode() === $y->__hashCode());
         }
     }
     return IBool\Type::false();
 }
Example #5
0
 /**
  * This method returns an item after removing it from the collection.
  *
  * @access public
  * @final
  * @param Core\Type $key                                    the key associated with the
  *                                                          item to be removed
  * @return Core\Type                                        the item removed
  */
 public final function removeKey(Core\Type $key) : Core\Type
 {
     $hashCode = $key->__hashCode();
     $item = IUnit\Type::instance();
     if (array_key_exists($hashCode, $this->value)) {
         $bucket = $this->value[$hashCode];
         $buffer = array();
         foreach ($bucket as $entry) {
             if ($entry->first()->__ne($key)) {
                 $buffer[] = $entry;
             } else {
                 $item = $entry->second();
             }
         }
         if (empty($buffer)) {
             unset($this->value[$hashCode]);
         } else {
             $this->value[$hashCode] = $buffer;
         }
     }
     return $item;
 }
Example #6
0
 /**
  * This method evaluates whether the specified object is identical to the current object.
  *
  * @access public
  * @static
  * @param IString\Type $xs                                  the left operand
  * @param Core\Type $ys                                     the object to be evaluated
  * @return IBool\Type                                       whether the specified object is identical
  *                                                          to the current object
  */
 public static function id(IString\Type $xs, Core\Type $ys) : IBool\Type
 {
     if ($ys !== null) {
         if ($xs->__typeOf() === $ys->__typeOf()) {
             return IBool\Type::box($xs->unbox() === $ys->unbox());
         }
     }
     return IBool\Type::false();
 }
Example #7
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param IInt32\Type $x                                    the left operand
  * @param Core\Type $y                                      the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(IInt32\Type $x, Core\Type $y) : IBool\Type
 {
     // ===
     if ($x->__typeOf() === $y->__typeOf()) {
         return IBool\Type::box($x->unbox() === $y->unbox());
     }
     return IBool\Type::false();
 }
Example #8
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param ITuple\Type $xs                                   the left operand
  * @param Core\Type $ys                                     the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(ITuple\Type $xs, Core\Type $ys) : IBool\Type
 {
     // ===
     if ($xs->__typeOf() === $ys->__typeOf()) {
         return IBool\Type::box(ITuple\Module::compare($xs, $ys)->unbox() == 0);
     }
     return IBool\Type::false();
 }
Example #9
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param IHashMap\Type $xs                                 the left operand
  * @param Core\Type $ys                                     the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(IHashMap\Type $xs, Core\Type $ys) : IBool\Type
 {
     // ===
     if ($ys !== null && $xs->__typeOf() === $ys->__typeOf()) {
         if (IInt32\Module::eq($xs->size(), $ys->size())) {
             return IBool\Type::box((string) serialize($xs) == (string) serialize($ys));
         }
     }
     return IBool\Type::false();
 }
Example #10
0
 /**
  * This method returns the object's class type.
  *
  * @access public
  * @static
  * @param Core\Type $x                                      the object to be evaluated
  * @return IString\Type                                     the object's class type
  */
 public static function typeOf(Core\Type $x) : IString\Type
 {
     return $x->typeOf();
 }
Example #11
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param IRatio\Type $x                                    the left operand
  * @param Core\Type $y                                      the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(IRatio\Type $x, Core\Type $y) : IBool\Type
 {
     // ===
     if ($x->__typeOf() === $y->__typeOf()) {
         return IBool\Module::and_(IInt32\Module::id($x->numerator(), $y->numerator()), IInt32\Module::id($x->denominator(), $y->denomintor()));
     }
     return IBool\Type::false();
 }
Example #12
0
 /**
  * This method returns the hash set with the item removed.
  *
  * @access public
  * @final
  * @param Core\Type $item                                   the item to be removed
  * @return IHashSet\Type                                    the hash set
  */
 public final function removeItem(Core\Type $item) : IHashSet\Type
 {
     $hashCode = $item->__hashCode();
     if (array_key_exists($hashCode, $this->value)) {
         $bucket = $this->value[$hashCode];
         $type = $item->__typeOf();
         $buffer = array();
         foreach ($bucket as $entry) {
             if ($type != $entry->__typeOf()) {
                 $buffer[] = $entry;
             }
         }
         if (empty($buffer)) {
             unset($this->value[$hashCode]);
         } else {
             $this->value[$hashCode] = $buffer;
         }
     }
     return $this;
 }
Example #13
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param IArrayList\Type $xs                               the left operand
  * @param Core\Type $ys                                     the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(IArrayList\Type $xs, Core\Type $ys) : IBool\Type
 {
     // ===
     if ($ys !== null) {
         if ($xs->__typeOf() === $ys->__typeOf()) {
             $x_length = $xs->__length();
             $y_length = $ys->__length();
             for ($i = 0; $i < $x_length && $i < $y_length; $i++) {
                 $p = IInt32\Type::box($i);
                 $r = $xs->item($p)->id($ys->item($p));
                 if (!$r->unbox()) {
                     return $r;
                 }
             }
             return IBool\Type::box($x_length == $y_length);
         }
     }
     return IBool\Type::false();
 }
Example #14
0
 /**
  * This method evaluates whether the left operand is identical to the right operand.
  *
  * @access public
  * @static
  * @param ILinkedList\Type $xs                              the left operand
  * @param Core\Type $ys                                     the right operand
  * @return IBool\Type                                       whether the left operand is identical
  *                                                          to the right operand
  */
 public static function id(ILinkedList\Type $xs, Core\Type $ys) : IBool\Type
 {
     // ===
     if ($ys !== null && $xs->__typeOf() == $ys->typeOf()) {
         for ($as = $xs, $bs = $ys; !$as->__isEmpty() && !$bs->__isEmpty(); $as = $as->tail(), $bs = $bs->tail()) {
             $r = $as->head()->id($bs->head());
             if (!$r->unbox()) {
                 return $r;
             }
         }
         $x_length = $xs->__length();
         $y_length = $ys->__length();
         if ($x_length == $y_length) {
             return IBool\Type::true();
         }
     }
     return IBool\Type::false();
 }