/** * @return boolean Wether the action was successfull or not */ public function addAll(\blaze\collections\Collection $obj) { $ar = $obj->toArray(); foreach ($ar as $val) { $this->add($val); } }
/** * @return boolean Wether the action was successfull or not */ public function removeAll(\blaze\collections\Collection $obj) { $ar = $obj->toArray(); $ret = false; foreach ($ar as $value) { if ($this->remove($value)) { $ret = true; } } return $ret; }
public function toArray($type = null) { return $this->collection->toArray($type); }
/** * @return boolean Wether the action was successfull or not */ public function retainAll(\blaze\collections\Collection $obj) { $retained = array(); $arr = $obj->toArray(); for ($i = 0; $i < $this->size; $i++) { for ($j = 0; $j < $obj->size(); $j++) { if ($this->data[$i]->equals($arr[$j])) { $retained[] = $this->data[$i]; break; } } } $changed = count($retained) != $this->size; $this->size = count($retained); $this->data = $retained; return $changed; }
/** * Returns the minimum element of the given collection, according to the natural ordering of its elements. */ public static function min(Collection $src, \blaze\lang\Comparator $comp = null) { if ($src->size() == 0) { return null; } $arr = $src->toArray(); $min = $arr[0]; foreach ($arr as $val) { if ($comp == null && $min->compareTo($val) > 0 || $comp != null && $comp->compare($min, $val) > 0) { $min = $val; } } return $min; }
/** * @return boolean Wether the action was successfull or not */ public function removeAll(\blaze\collections\Collection $obj) { $ar = $obj->toArray(); $ret = false; for ($i = 0; $i < count($ar); $i++) { if ($this->remove($ar[$i])) { $ret = true; } } return $ret; }