Created
October 1, 2014 19:25
-
-
Save DarkSeraphim/d298007d5291d0a4b1ce to your computer and use it in GitHub Desktop.
It's... so pwetty - forwarding the Iterator removal for wrapped object Lists to the unwrapped object variant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<Trade> trades = new ArrayList<Trade>() | |
| { | |
| public Iterator<Trade> iterator() | |
| { | |
| final Iterator<Trade> s = super.iterator(); | |
| return new Iterator<Trade>() | |
| { | |
| private final List<?> nmsList = list; | |
| private final Iterator<Trade> delegate = s; | |
| private Trade last; | |
| @Override | |
| public boolean hasNext() | |
| { | |
| return this.delegate.hasNext(); | |
| } | |
| @Override | |
| public Trade next() | |
| { | |
| return this.last = this.delegate.next(); | |
| } | |
| @Override | |
| public void remove() | |
| { | |
| this.delegate.remove(); | |
| this.nmsList.remove(unwrap(this.last)); | |
| } | |
| }; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment