/** * This method evaluates whether the left operand is equal 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 equal * to the right operand */ public static function eq(IHashMap\Type $xs, Core\Type $ys) : IBool\Type { // == $type = $xs->__typeOf(); if ($ys !== null && $ys instanceof $type) { if (IInt32\Module::__eq($xs->size(), $ys->size())) { return IHashMap\Module::all($xs, function (ITuple\Type $x, IInt32\Type $i) use($ys) { $key = $x->first(); if ($ys->__hasKey($key)) { return $ys->item($key)->eq($x->second()); } return IBool\Type::false(); }); } } return IBool\Type::false(); }
/** * 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(); }
/** * 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(); }