Replaces while iterators with foreach call

This commit is contained in:
thatsIch 2014-09-29 09:26:35 +02:00
parent 72106c877d
commit b6ec21c70a
10 changed files with 33 additions and 36 deletions

View file

@ -394,11 +394,10 @@ public abstract class AEBaseGui extends GuiContainer
else if ( dbl_whichItem != null )
{
// a replica of the weird broken vanilla feature.
Iterator iterator = this.inventorySlots.inventorySlots.iterator();
while (iterator.hasNext())
for (Object inventorySlot : this.inventorySlots.inventorySlots)
{
Slot targetSlot = (Slot) iterator.next();
Slot targetSlot = (Slot) inventorySlot;
if ( targetSlot != null && targetSlot.canTakeStack( this.mc.thePlayer ) && targetSlot.getHasStack()
&& targetSlot.inventory == slot.inventory && Container.func_94527_a( targetSlot, dbl_whichItem, true ) )

View file

@ -251,12 +251,12 @@ public class GuiCraftConfirm extends AEBaseGui
private IAEItemStack findVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = visual.iterator();
while (i.hasNext())
for (IAEItemStack o : visual)
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
{
return o;
}
}
IAEItemStack stack = l.copy();

View file

@ -169,12 +169,12 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
private IAEItemStack findVisualStack(IAEItemStack l)
{
Iterator<IAEItemStack> i = visual.iterator();
while (i.hasNext())
for (IAEItemStack o : visual)
{
IAEItemStack o = i.next();
if ( o.equals( l ) )
{
return o;
}
}
IAEItemStack stack = l.copy();

View file

@ -209,12 +209,12 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
if ( machine instanceof ICraftingRequester )
{
Iterator<CraftingLinkNexus> nex = links.values().iterator();
while (nex.hasNext())
for (CraftingLinkNexus n : links.values())
{
CraftingLinkNexus n = nex.next();
if ( n.isMachine( machine ) )
{
n.removeNode();
}
}
}

View file

@ -89,15 +89,15 @@ public class CellInventory implements ICellInventory
// add new pretty stuff...
int x = 0;
Iterator<IAEItemStack> i = cellItems.iterator();
while (i.hasNext())
for (IAEItemStack v : cellItems)
{
IAEItemStack v = i.next();
itemCount += v.getStackSize();
NBTBase c = tagCompound.getTag( ITEM_SLOT_ARR[x] );
if ( c instanceof NBTTagCompound )
{
v.writeToNBT( (NBTTagCompound) c );
}
else
{
NBTTagCompound g = new NBTTagCompound();

View file

@ -155,12 +155,8 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
return input;
}
Iterator<List<IMEInventoryHandler<T>>> i = priorityInventory.values().iterator();// asMap().entrySet().iterator();
while (i.hasNext())
for (List<IMEInventoryHandler<T>> invList : priorityInventory.values())
{
List<IMEInventoryHandler<T>> invList = i.next();
Iterator<IMEInventoryHandler<T>> ii = invList.iterator();
while (ii.hasNext() && input != null)
{
@ -168,7 +164,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
if ( inv.validForPass( 1 ) && inv.canAccept( input )
&& (inv.isPrioritized( input ) || inv.extractItems( input, Actionable.SIMULATE, src ) != null) )
{
input = inv.injectItems( input, type, src );
}
}
ii = invList.iterator();
@ -176,7 +174,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
{
IMEInventoryHandler<T> inv = ii.next();
if ( inv.validForPass( 2 ) && inv.canAccept( input ) )// ignore crafting on the second pass.
{
input = inv.injectItems( input, type, src );
}
}
}

View file

@ -79,13 +79,12 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
if ( slot != null )
{
boolean inRecipe = false;
Iterator<Object> req = required.iterator();
while (req.hasNext())
for (Object aRequired : required)
{
boolean match = false;
Object next = req.next();
Object next = aRequired;
if ( next instanceof IIngredient )
{

View file

@ -399,17 +399,19 @@ public class Platform
if ( cA.size() != cB.size() )
return false;
Iterator<String> i = cA.iterator();
while (i.hasNext())
for (String name : cA)
{
String name = i.next();
NBTBase tag = ctA.getTag( name );
NBTBase aTag = ctB.getTag( name );
if ( aTag == null )
{
return false;
}
if ( !NBTEqualityTest( tag, aTag ) )
{
return false;
}
}
return true;
@ -521,10 +523,8 @@ public class Platform
Set<String> cA = ctA.func_150296_c();
Iterator<String> i = cA.iterator();
while (i.hasNext())
for (String name : cA)
{
String name = i.next();
hash += name.hashCode() ^ NBTOrderlessHash( ctA.getTag( name ) );
}

View file

@ -58,11 +58,9 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
AESharedNBT x = new AESharedNBT( itemID, damageValue );
// c.getTags()
Iterator var2 = c.func_150296_c().iterator();
while (var2.hasNext())
for (Object o : c.func_150296_c())
{
String name = (String) var2.next();
String name = (String) o;
x.setTag( name, c.getTag( name ).copy() );
}

View file

@ -135,9 +135,10 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
@Override
synchronized public StackType getFirstItem()
{
Iterator<StackType> i = this.iterator();
while (i.hasNext())
return i.next();
for (StackType stackType : this)
{
return stackType;
}
return null;
}