use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.
the class ServerImpl method sendEntities.
private void sendEntities(NetData.NetMessage.Builder message) {
TIntIterator dirtyIterator = netDirty.iterator();
while (dirtyIterator.hasNext()) {
int netId = dirtyIterator.next();
EntityRef entity = networkSystem.getEntity(netId);
if (isOwned(entity)) {
Set<Class<? extends Component>> emptyComponentClassSet = Collections.emptySet();
EntityData.PackedEntity entityData = entitySerializer.serialize(entity, emptyComponentClassSet, changedComponents.get(netId), emptyComponentClassSet, new ClientComponentFieldCheck());
if (entityData != null) {
message.addUpdateEntity(NetData.UpdateEntityMessage.newBuilder().setEntity(entityData).setNetId(netId));
}
}
}
netDirty.clear();
}
use of gnu.trove.iterator.TIntIterator in project Charset by CharsetMC.
the class AudioStreamManagerClient method removeAll.
@Override
public void removeAll() {
TIntIterator iterator = streams.keySet().iterator();
while (iterator.hasNext()) {
streams.get(iterator.next()).stop();
}
streams.clear();
}
use of gnu.trove.iterator.TIntIterator in project Charset by CharsetMC.
the class IngredientGroup method createMatchingStacks.
@Override
protected ItemStack[][] createMatchingStacks() {
TIntList list = new TIntArrayList();
Entry e = entryMap.get(type);
if (e == null) {
return new ItemStack[0][0];
}
TIntIterator iterator = e.typeMap.keySet().iterator();
while (iterator.hasNext()) {
int id = iterator.next();
if (!blacklistedIds.contains(id)) {
list.add(id);
}
}
ItemStack[][] stacks = new ItemStack[list.size()][];
for (int i = 0; i < stacks.length; i++) {
Collection c = e.typeMap.get(list.get(i));
int length = 0;
for (Object o : c) {
if (o instanceof String) {
length += OreDictionary.getOres((String) o).size();
} else if (o instanceof ItemStack) {
length++;
}
}
stacks[i] = new ItemStack[length];
int j = 0;
for (Object o : c) {
if (o instanceof String) {
NonNullList<ItemStack> stackList = OreDictionary.getOres((String) o);
for (ItemStack stack : stackList) {
stacks[i][j++] = stack;
}
} else if (o instanceof ItemStack) {
stacks[i][j++] = (ItemStack) o;
}
}
}
return stacks;
}
use of gnu.trove.iterator.TIntIterator in project Osmand by osmandapp.
the class RouteResultPreparation method inferSlightTurnFromLanes.
private int inferSlightTurnFromLanes(int[] oLanes, RoadSplitStructure rs) {
TIntHashSet possibleTurns = new TIntHashSet();
for (int i = 0; i < oLanes.length; i++) {
if ((oLanes[i] & 1) == 0) {
continue;
}
if (possibleTurns.isEmpty()) {
// Nothing is in the list to compare to, so add the first elements
possibleTurns.add(TurnType.getPrimaryTurn(oLanes[i]));
if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
possibleTurns.add(TurnType.getSecondaryTurn(oLanes[i]));
}
if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
possibleTurns.add(TurnType.getTertiaryTurn(oLanes[i]));
}
} else {
TIntArrayList laneTurns = new TIntArrayList();
laneTurns.add(TurnType.getPrimaryTurn(oLanes[i]));
if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
laneTurns.add(TurnType.getSecondaryTurn(oLanes[i]));
}
if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
laneTurns.add(TurnType.getTertiaryTurn(oLanes[i]));
}
possibleTurns.retainAll(laneTurns);
if (possibleTurns.isEmpty()) {
// No common turns, so can't determine anything.
return 0;
}
}
}
// Remove all turns from lanes not selected...because those aren't it
for (int i = 0; i < oLanes.length; i++) {
if ((oLanes[i] & 1) == 0 && !possibleTurns.isEmpty()) {
possibleTurns.remove((Integer) TurnType.getPrimaryTurn(oLanes[i]));
if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
possibleTurns.remove((Integer) TurnType.getSecondaryTurn(oLanes[i]));
}
if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
possibleTurns.remove((Integer) TurnType.getTertiaryTurn(oLanes[i]));
}
}
}
// remove all non-slight turns // TEST don't pass
// if(possibleTurns.size() > 1) {
// TIntIterator it = possibleTurns.iterator();
// while(it.hasNext()) {
// int nxt = it.next();
// if(!TurnType.isSlightTurn(nxt)) {
// it.remove();
// }
// }
// }
int infer = 0;
if (possibleTurns.size() == 1) {
infer = possibleTurns.iterator().next();
} else if (possibleTurns.size() > 1) {
if (rs.keepLeft && rs.keepRight && possibleTurns.contains(TurnType.C)) {
infer = TurnType.C;
} else if (rs.keepLeft || rs.keepRight) {
TIntIterator it = possibleTurns.iterator();
infer = it.next();
while (it.hasNext()) {
int next = it.next();
int orderInfer = TurnType.orderFromLeftToRight(infer);
int orderNext = TurnType.orderFromLeftToRight(next);
if (rs.keepLeft && orderNext < orderInfer) {
infer = next;
} else if (rs.keepRight && orderNext > orderInfer) {
infer = next;
}
}
}
}
// Checking to see that there is only one unique turn
if (infer != 0) {
for (int i = 0; i < oLanes.length; i++) {
if (TurnType.getSecondaryTurn(oLanes[i]) == infer) {
int pt = TurnType.getPrimaryTurn(oLanes[i]);
int en = oLanes[i] & 1;
TurnType.setPrimaryTurnAndReset(oLanes, i, infer);
oLanes[i] |= en;
TurnType.setSecondaryTurn(oLanes, i, pt);
}
}
}
return infer;
}
use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.
the class NetClient method sendRemovedEntities.
private void sendRemovedEntities(NetData.NetMessage.Builder message) {
TIntIterator initialIterator = netRemoved.iterator();
while (initialIterator.hasNext()) {
message.addRemoveEntity(NetData.RemoveEntityMessage.newBuilder().setNetId(initialIterator.next()));
}
netRemoved.clear();
}
Aggregations