71 if (!is_int($inf) && !is_string($inf))
73 throw new IllegalValueException(
'Inf must be NULL, integer or string');
75 foreach($this->iterators as $iter)
77 if ($inf == $this->iterators->getInfo())
79 throw new IllegalValueException(
'Key duplication error');
83 $this->iterators->attach($iter, $inf);
89 $this->iterators->detach($iter);
97 return $this->iterator->contains($iter);
103 return $this->iterators->count();
109 foreach($this->iterators as $iter)
124 if (!
sizeof($this->iterators)) {
129 $expect = $this->flags & self::MIT_NEED_ALL ?
true :
false;
130 foreach($this->iterators as $iter)
132 if ($expect != $iter->valid())
145 foreach($this->iterators as $iter)
159 if (!
sizeof($this->iterators))
164 foreach($this->iterators as $iter)
168 if ($this->flags & self::MIT_KEYS_ASSOC)
170 $key = $this->iterators->getInfo();
173 throw new IllegalValueException(
'Sub-Iterator is associated with NULL');
175 $retval[$key] = $iter->current();
179 $retval[] = $iter->current();
182 else if ($this->flags & self::MIT_NEED_ALL)
201 if (!
sizeof($this->iterators))
206 foreach($this->iterators as $iter)
210 $retval[] = $iter->key();
212 else if ($this->flags & self::MIT_NEED_ALL)
214 throw new LogicException(
'Called key() with non valid sub iterator');
$flags
Flags: const MIT_*.
__construct($flags=self::MIT_NEED_ALL|self::MIT_KEYS_NUMERIC)
Construct a new empty MultipleIterator.
const MIT_NEED_ANY
do not require all sub iterators to be valid in iteration
const MIT_KEYS_ASSOC
keys are created from sub iterators associated infromation
$iterators
Inner Iterators.
const MIT_NEED_ALL
require all sub iterators to be valid in iteration
next()
Move all attached Iterator instances forward.
attachIterator(Iterator $iter, $inf=NULL)
Iterator that iterates over several iterators one after the other.
containsIterator(Iterator $iter)
const MIT_KEYS_NUMERIC
keys are created from sub iterators position
Exception that represents error in the program logic.
rewind()
Rewind all attached Iterator instances.
Exception thrown for errors that are only detectable at runtime.
detachIterator(Iterator $iter)