/** * 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 adds the item with the specified key to the hash map (if it doesn't * already exist). * * @access public * @static * @param IHashMap\Type $xs the hash map * @param ITuple\Type $entry the key/value pair to be put * in the hash map * @return IHashMap\Type the hash map */ public static function putEntry(IHashMap\Type $xs, ITuple\Type $entry) : IHashMap\Type { $zs = IHashMap\Type::box($xs->unbox()); $zs->putEntry($entry->first(), $entry->second()); return $zs; }
/** * This method returns a new string after replacing any matches with the specified * replacement. * * @access public * @static * @param IRegex\Type $x the regular expression * @param ITuple\Type $ys a tuple containing the replacement * and the object that is the subject * @return IString\Type the string after being processed */ public static function replace(IRegex\Type $x, ITuple\Type $ys) : IString\Type { return IString\Type::box(preg_replace($x->unbox(), $ys->first()->__toString(), $ys->second()->__toString())); }
/** * This method returns a tuple with the items swapped. * * @access public * @static * @param ITuple\Type $xs the left operand * @return ITuple\Type a tuple with the item swapped */ public static function swap(ITuple\Type $xs) : ITuple\Type { return ITuple\Type::box2($xs->second(), $xs->first()); }