Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ListIterator::__construct($list){
- $list->addIterator();
- }
- ListIterator::__destruct(){
- $this->list->removeIterator();
- }
- List::remove($index){
- if($this->iteratorsCount > 0){ throw new ConcurrentModificationError(); }
- /* ... */
- }
- vs
- ListIterator::__construct($list){
- $this->watch = function(){ $this->list = clone $this->list; };
- $this->list->addBeforeChange($this->watch);
- }
- ListIterator::__destruct(){
- $this->list->removeBeforeChange($this->watch);
- }
- List::remove($index){
- $this->notifyChanging();
- /* ... */
- }
Advertisement
Add Comment
Please, Sign In to add comment