storage); } /** @return whether iterator is valid */ function valid() { return key($this->storage) !== false; } /** @return current key */ function key() { return $this->index; } /** @return current object */ function current() { return current($this->storage); } /** Forward to next element */ function next() { next($this->storage); $this->index++; } /** @return number of objects in storage */ function count() { return count($this->storage); } /** @param obj object to look for * @return whether $obj is contained in storage */ function contains($obj) { if (is_object($obj)) { foreach($this->storage as $object) { if ($object === $obj) { return true; } } } return false; } /** @param $obj new object to attach to storage if not yet contained */ function attach($obj) { if (is_object($obj) && !$this->contains($obj)) { $this->storage[] = $obj; } } /** @param $obj object to remove from storage */ function detach($obj) { if (is_object($obj)) { foreach($this->storage as $idx => $object) { if ($object === $obj) { unset($this->storage[$idx]); $this->rewind(); return; } } } } } ?>