Implement correct Iterator type
This commit is contained in:
parent
add0bd41e4
commit
016a6410aa
1 changed files with 15 additions and 10 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue