class RuleWatchChain
An extension of SplDoublyLinkedList with seek and removal of current element
SplDoublyLinkedList only allows deleting a particular offset and has no method to set the internal iterator to a particular offset.
@author Nils Adermann <naderman@naderman.de> @extends \SplDoublyLinkedList<RuleWatchNode>
Hierarchy
- class \Composer\DependencyResolver\RuleWatchChain extends \Composer\DependencyResolver\SplDoublyLinkedList
Expanded class hierarchy of RuleWatchChain
File
-
vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ RuleWatchChain.php, line 24
Namespace
Composer\DependencyResolverView source
class RuleWatchChain extends \SplDoublyLinkedList {
/**
* Moves the internal iterator to the specified offset
*
* @param int $offset The offset to seek to.
*/
public function seek(int $offset) : void {
$this->rewind();
for ($i = 0; $i < $offset; $i++, $this->next()) {
}
}
/**
* Removes the current element from the list
*
* As SplDoublyLinkedList only allows deleting a particular offset and
* incorrectly sets the internal iterator if you delete the current value
* this method sets the internal iterator back to the following element
* using the seek method.
*/
public function remove() : void {
$offset = $this->key();
$this->offsetUnset($offset);
$this->seek($offset);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
RuleWatchChain::remove | public | function | Removes the current element from the list |
RuleWatchChain::seek | public | function | Moves the internal iterator to the specified offset |