package appeng.me; import java.util.HashMap; import java.util.Iterator; import java.util.Set; import appeng.api.networking.IGridNode; import appeng.api.util.IReadOnlyCollection; public class NodeIterable implements IReadOnlyCollection { final private HashMap> Machines; public NodeIterable(HashMap> Machines) { this.Machines = Machines; } @Override public Iterator iterator() { return new NodeIterator( Machines ); } @Override public int size() { int size = 0; for (Set o : Machines.values()) size += o.size(); return size; } @Override public boolean isEmpty() { for (Set o : Machines.values()) if ( !o.isEmpty() ) return false; return true; } @Override public boolean contains(Object node) { Class c = ((IGridNode) node).getMachine().getClass(); Set p = Machines.get( c ); if ( p != null ) return p.contains( node ); return false; } }