Guest User

Untitled

a guest
Mar 5th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. ListIterator::__construct($list){
  2. $list->addIterator();
  3. }
  4. ListIterator::__destruct(){
  5. $this->list->removeIterator();
  6. }
  7. List::remove($index){
  8. if($this->iteratorsCount > 0){ throw new ConcurrentModificationError(); }
  9. /* ... */
  10. }
  11.  
  12. vs
  13.  
  14. ListIterator::__construct($list){
  15. $this->watch = function(){ $this->list = clone $this->list; };
  16. $this->list->addBeforeChange($this->watch);
  17. }
  18. ListIterator::__destruct(){
  19. $this->list->removeBeforeChange($this->watch);
  20. }
  21. List::remove($index){
  22. $this->notifyChanging();
  23. /* ... */
  24. }
Advertisement
Add Comment
Please, Sign In to add comment