Esempio n. 1
0
 /**
  * This method returns the size of the collection.
  *
  * @access public
  * @final
  * @return integer                                          the size of the collection
  */
 public final function count() : int
 {
     return $this->xs->__size();
 }
Esempio n. 2
0
 /**
  * This method compares the specified object with the current object for order.
  *
  * @access public
  * @static
  * @param IHashMap\Type $xs                                 the left operand
  * @param IHashMap\Type $ys                                 the object to be compared
  * @return ITrit\Type                                       whether the current object is less than,
  *                                                          equal to, or greater than the specified
  *                                                          object
  */
 public static function compare(IHashMap\Type $xs, IHashMap\Type $ys) : ITrit\Type
 {
     $x_length = $xs->__size();
     $y_length = $ys->__size();
     if ($x_length == $y_length) {
         $xi = IHashMap\Module::iterator($xs);
         foreach ($xi as $k => $v) {
             if (!$ys->__hasKey($k) || !$ys->item($k)->__eq($v)) {
                 return ITrit\Type::make(strcmp((string) serialize($xs), (string) serialize($ys)));
                 // order is not "stable"
             }
         }
         return ITrit\Type::zero();
     } else {
         if ($x_length < $y_length) {
             return ITrit\Type::negative();
         } else {
             // ($x_length > $y_length)
             return ITrit\Type::positive();
         }
     }
 }