4require_once
'Services/Contact/BuddySystem/interfaces/interface.ilBuddySystemCollection.php';
31 return new ArrayIterator($this->elements);
47 return $this->
get($offset);
55 if (!isset($offset)) {
60 $this->
set($offset, $value);
68 $this->
remove($offset);
76 return count($this->elements);
82 public function add($element)
84 $this->elements[] = $element;
90 public function remove(
$key)
92 if (!isset($this->elements[
$key]) && !array_key_exists(
$key, $this->elements)) {
93 throw new InvalidArgumentException(
sprintf(
"Could not find an element for key: ",
$key));
95 unset($this->elements[
$key]);
103 $key = array_search($element, $this->elements,
true);
104 if (
false ===
$key) {
105 throw new InvalidArgumentException(
"Could not find an key for the passed element.");
107 unset($this->elements[
$key]);
115 return isset($this->elements[
$key]) || array_key_exists(
$key, $this->elements);
124 return array_search($element, $this->elements,
true);
132 $this->elements = array();
140 return in_array($element, $this->elements,
true);
148 return isset($this->elements[
$key]) ? $this->elements[
$key] :
null;
154 public function set(
$key, $value)
156 $this->elements[
$key] = $value;
164 return empty($this->elements);
172 return array_keys($this->elements);
180 return array_values($this->elements);
188 return new static(array_filter($this->elements, $p));
194 public function slice($offset, $length =
null)
196 return new static(array_slice($this->elements, $offset, $length,
true));
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Class ilBuddySystemArrayCollection A collection which contains all entries of a buddy list.
offsetSet($offset, $value)
contains($element)
boolean true if the collection contains the element, false otherwise.
containsKey($key)
boolean true if the collection contains the element, false otherwise.
slice($offset, $length=null)
Extracts a slice of $length elements starting at position $offset from the Collection....
isEmpty()
boolean true if the collection is empty, false otherwise.
filter(Closure $p)
Returns all the elements of this collection that satisfy the predicate $callable.ilBuddySystemCollect...
__construct(array $elements=array())
getKeys()
Gets all indices of the collection.array The indices of the collection, in the order of the correspon...
add($element)
Adds an element at the end of the collection.
getValues()
Gets all values of the collection.array The values of all elements in the collection,...
Interface ilBuddySystemCollection.