This commit is contained in:
Calclavia 2013-08-04 22:07:04 -04:00
commit 01f871011f
2 changed files with 31 additions and 0 deletions

View file

@ -99,6 +99,36 @@ public class SetUtil
return newSet;
}
public static <V> Set<V> capRemains(Set<V> set, int cap)
{
Set<V> toReturn = new HashSet<V>();
if(set.size() <= cap)
{
return toReturn;
}
else {
Set<V> inverse = inverse(set);
int iterNeeded = set.size()-cap;
int count = 0;
for(V obj : set)
{
count++;
toReturn.add(obj);
if(count == iterNeeded)
{
break;
}
}
return toReturn;
}
}
/**
* Splits a set into the defined amount of new sets, and returns them in an ArrayList.
* @param set - set to split

View file

@ -219,6 +219,7 @@ public class BatteryUpdateProtocol
{
ArrayList<Set<ItemStack>> inventories = SetUtil.split(oldStructure.inventory, iteratedNodes.size());
List<TileEntityBattery> iterList = SetUtil.asList(iteratedNodes);
boolean didVisibleInventory = false;
for(int i = 0; i < iterList.size(); i++)