Esempio n. 1
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;
 }
Esempio n. 2
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();
 }
Esempio n. 3
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;
 }