A bit of work on logistics
This commit is contained in:
parent
ab02a09159
commit
a26a698b4b
2 changed files with 31 additions and 0 deletions
|
@ -99,6 +99,36 @@ public class SetUtil
|
||||||
return newSet;
|
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.
|
* Splits a set into the defined amount of new sets, and returns them in an ArrayList.
|
||||||
* @param set - set to split
|
* @param set - set to split
|
||||||
|
|
|
@ -219,6 +219,7 @@ public class BatteryUpdateProtocol
|
||||||
{
|
{
|
||||||
ArrayList<Set<ItemStack>> inventories = SetUtil.split(oldStructure.inventory, iteratedNodes.size());
|
ArrayList<Set<ItemStack>> inventories = SetUtil.split(oldStructure.inventory, iteratedNodes.size());
|
||||||
List<TileEntityBattery> iterList = SetUtil.asList(iteratedNodes);
|
List<TileEntityBattery> iterList = SetUtil.asList(iteratedNodes);
|
||||||
|
|
||||||
boolean didVisibleInventory = false;
|
boolean didVisibleInventory = false;
|
||||||
|
|
||||||
for(int i = 0; i < iterList.size(); i++)
|
for(int i = 0; i < iterList.size(); i++)
|
||||||
|
|
Loading…
Reference in a new issue