4require_once
'Services/Contact/BuddySystem/interfaces/interface.ilBuddySystemCollection.php';
31 return new ArrayIterator($this->elements);
47 return $this->
get($offset);
61 $this->
set($offset, $value);
69 $this->
remove($offset);
77 return count($this->elements);
83 public function add($element)
85 $this->elements[] = $element;
91 public function remove($key)
93 if(!isset($this->elements[$key]) && !array_key_exists($key, $this->elements))
95 throw new InvalidArgumentException(sprintf(
"Could not find an element for key: ", $key));
97 unset($this->elements[$key]);
105 $key = array_search($element, $this->elements,
true);
108 throw new InvalidArgumentException(
"Could not find an key for the passed element.");
110 unset($this->elements[$key]);
118 return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
127 return array_search($element, $this->elements,
true);
135 $this->elements = array();
143 return in_array($element, $this->elements,
true);
149 public function get($key)
151 return isset($this->elements[$key]) ? $this->elements[$key] :
null;
157 public function set($key, $value)
159 $this->elements[$key] = $value;
167 return empty($this->elements);
175 return array_keys($this->elements);
183 return array_values($this->elements);
191 return new static(array_filter($this->elements, $p));
197 public function slice($offset, $length =
null)
199 return new static(array_slice($this->elements, $offset, $length,
true));
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.