/** * This method returns the length of the collection. * * @access public * @final * @return int the length of the collection */ public final function count() : int { return $this->xs->__length(); }
/** * This method compares the operands for order. * * @access public * @static * @param ILinkedList\Type $xs the left operand * @param ILinkedList\Type $ys the right operand * @return ITrit\Type the order as to whether the left * operand is less than, equals to, * or greater than the right operand */ public static function compare(ILinkedList\Type $xs, ILinkedList\Type $ys) : ITrit\Type { for ($as = $xs, $bs = $ys; !$as->__isEmpty() && !$bs->__isEmpty(); $as = $as->tail(), $bs = $bs->tail()) { $r = $as->head()->compare($bs->head()); if ($r->unbox() != 0) { return $r; } } return ITrit\Type::box($xs->__length() <=> $ys->__length()); }