Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
+125 -123
View File
@@ -18,6 +18,7 @@
package appeng.crafting;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -27,12 +28,134 @@ import appeng.api.networking.crafting.ICraftingWatcherHost;
import appeng.api.storage.data.IAEStack;
import appeng.me.cache.CraftingGridCache;
/**
* Maintain my interests, and a global watch list, they should always be fully synchronized.
*/
public class CraftingWatcher implements ICraftingWatcher
{
final CraftingGridCache gsc;
final ICraftingWatcherHost host;
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
public CraftingWatcher( CraftingGridCache cache, ICraftingWatcherHost host )
{
this.gsc = cache;
this.host = host;
}
public ICraftingWatcherHost getHost()
{
return this.host;
}
@Override
public int size()
{
return this.myInterests.size();
}
@Override
public boolean isEmpty()
{
return this.myInterests.isEmpty();
}
@Override
public boolean contains( Object o )
{
return this.myInterests.contains( o );
}
@Override
public Iterator<IAEStack> iterator()
{
return new ItemWatcherIterator( this, this.myInterests.iterator() );
}
@Override
public Object[] toArray()
{
return this.myInterests.toArray();
}
@Override
public <T> T[] toArray( T[] a )
{
return this.myInterests.toArray( a );
}
@Override
public boolean add( IAEStack e )
{
if( this.myInterests.contains( e ) )
return false;
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
}
@Override
public boolean remove( Object o )
{
return this.myInterests.remove( o ) && this.gsc.interestManager.remove( (IAEStack) o, this );
}
@Override
public boolean containsAll( Collection<?> c )
{
return this.myInterests.containsAll( c );
}
@Override
public boolean addAll( Collection<? extends IAEStack> c )
{
boolean didChange = false;
for( IAEStack o : c )
didChange = this.add( o ) || didChange;
return didChange;
}
@Override
public boolean removeAll( Collection<?> c )
{
boolean didSomething = false;
for( Object o : c )
didSomething = this.remove( o ) || didSomething;
return didSomething;
}
@Override
public boolean retainAll( Collection<?> c )
{
boolean changed = false;
Iterator<IAEStack> i = this.iterator();
while( i.hasNext() )
{
if( !c.contains( i.next() ) )
{
i.remove();
changed = true;
}
}
return changed;
}
@Override
public void clear()
{
Iterator<IAEStack> i = this.myInterests.iterator();
while( i.hasNext() )
{
this.gsc.interestManager.remove( i.next(), this );
i.remove();
}
}
class ItemWatcherIterator implements Iterator<IAEStack>
{
@@ -40,7 +163,8 @@ public class CraftingWatcher implements ICraftingWatcher
final Iterator<IAEStack> interestIterator;
IAEStack myLast;
public ItemWatcherIterator(CraftingWatcher parent, Iterator<IAEStack> i) {
public ItemWatcherIterator( CraftingWatcher parent, Iterator<IAEStack> i )
{
this.watcher = parent;
this.interestIterator = i;
}
@@ -63,127 +187,5 @@ public class CraftingWatcher implements ICraftingWatcher
CraftingWatcher.this.gsc.interestManager.remove( this.myLast, this.watcher );
this.interestIterator.remove();
}
}
final CraftingGridCache gsc;
final ICraftingWatcherHost host;
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
public CraftingWatcher(CraftingGridCache cache, ICraftingWatcherHost host) {
this.gsc = cache;
this.host = host;
}
public ICraftingWatcherHost getHost()
{
return this.host;
}
@Override
public boolean add(IAEStack e)
{
if ( this.myInterests.contains( e ) )
return false;
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
}
@Override
public boolean addAll(Collection<? extends IAEStack> c)
{
boolean didChange = false;
for (IAEStack o : c)
didChange = this.add( o ) || didChange;
return didChange;
}
@Override
public void clear()
{
Iterator<IAEStack> i = this.myInterests.iterator();
while (i.hasNext())
{
this.gsc.interestManager.remove( i.next(), this );
i.remove();
}
}
@Override
public boolean contains(Object o)
{
return this.myInterests.contains( o );
}
@Override
public boolean containsAll(Collection<?> c)
{
return this.myInterests.containsAll( c );
}
@Override
public boolean isEmpty()
{
return this.myInterests.isEmpty();
}
@Override
public Iterator<IAEStack> iterator()
{
return new ItemWatcherIterator( this, this.myInterests.iterator() );
}
@Override
public boolean remove(Object o)
{
return this.myInterests.remove( o ) && this.gsc.interestManager.remove( (IAEStack) o, this );
}
@Override
public boolean removeAll(Collection<?> c)
{
boolean didSomething = false;
for (Object o : c)
didSomething = this.remove( o ) || didSomething;
return didSomething;
}
@Override
public boolean retainAll(Collection<?> c)
{
boolean changed = false;
Iterator<IAEStack> i = this.iterator();
while (i.hasNext())
{
if ( !c.contains( i.next() ) )
{
i.remove();
changed = true;
}
}
return changed;
}
@Override
public int size()
{
return this.myInterests.size();
}
@Override
public Object[] toArray()
{
return this.myInterests.toArray();
}
@Override
public <T> T[] toArray(T[] a)
{
return this.myInterests.toArray( a );
}
}