Implement correct Iterator type

This commit is contained in:
thatsIch 2014-10-05 12:04:20 +02:00
parent add0bd41e4
commit 016a6410aa

View file

@ -4,35 +4,40 @@ import java.util.Iterator;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
public class MeaningfulIterator<StackType extends IAEStack> implements Iterator public class MeaningfulIterator<StackType extends IAEStack> implements Iterator<StackType>
{ {
final Iterator<StackType> parent; private final Iterator<StackType> parent;
private StackType next; private StackType next;
public MeaningfulIterator(Iterator<StackType> iterator) { public MeaningfulIterator(Iterator<StackType> iterator)
parent = iterator; {
this.parent = iterator;
} }
@Override @Override
public boolean hasNext() public boolean hasNext()
{ {
while (parent.hasNext()) while (this.parent.hasNext())
{
this.next = this.parent.next();
if ( this.next.isMeaningful() )
{ {
next = parent.next();
if ( next.isMeaningful() )
return true; return true;
}
else else
parent.remove(); // self cleaning :3 {
this.parent.remove(); // self cleaning :3
}
} }
return false; return false;
} }
@Override @Override
public Object next() public StackType next()
{ {
return next; return this.next;
} }
@Override @Override