Search in sources :

Example 56 with Entry

use of java.util.Map.Entry in project BluePower by Qmunity.

the class GateTransceiver method propagate.

@Override
public Collection<Entry<IConnection<IRedstoneDevice>, Boolean>> propagate(ForgeDirection fromSide) {
    List<Entry<IConnection<IRedstoneDevice>, Boolean>> l = new ArrayList<Entry<IConnection<IRedstoneDevice>, Boolean>>();
    if (frequency == null)
        return l;
    l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(getRedstoneConnectionCache().getConnectionOnSide(fromSide), false));
    for (IWirelessDevice d : WirelessManager.COMMON_INSTANCE.getDevices()) {
        if (d != this && d.getFrequency() != null && d.getFrequency().equals(getFrequency())) {
            if (d instanceof GateTransceiver) {
                IConnection<IRedstoneDevice> c = ((GateTransceiver) d).getRedstoneConnectionCache().getConnectionOnSide(((GateTransceiver) d).front().getForgeDirection());
                if (c != null)
                    l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(c, false));
            }
        }
    }
    return l;
}
Also used : Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) IConnection(com.bluepowermod.api.connect.IConnection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice) IWirelessDevice(com.bluepowermod.api.wireless.IWirelessDevice) Pair(uk.co.qmunity.lib.misc.Pair)

Example 57 with Entry

use of java.util.Map.Entry in project LogisticsPipes by RS485.

the class ModuleCCBasedQuickSort method handleSinkResponses.

private void handleSinkResponses(IInventoryUtil invUtil) {
    boolean changed = false;
    Iterator<Entry<Integer, Pair<Integer, List<CCSinkResponder>>>> iter = sinkResponses.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<Integer, Pair<Integer, List<CCSinkResponder>>> pair = iter.next();
        pair.getValue().setValue1(pair.getValue().getValue1() + 1);
        boolean canBeHandled = true;
        for (CCSinkResponder response : pair.getValue().getValue2()) {
            if (!response.isDone()) {
                canBeHandled = false;
                break;
            }
        }
        if (canBeHandled || pair.getValue().getValue1() > timeout) {
            // skip entry, if slot is not in the inventory (too high).
            boolean slotInInventory = pair.getKey() < invUtil.getSizeInventory();
            if (slotInInventory && handle(invUtil, pair.getKey(), pair.getValue().getValue2())) {
                stalled = false;
                lastSuceededStack = pair.getKey();
            }
            iter.remove();
            changed = true;
        }
    }
    if (changed) {
        checkSize();
    }
}
Also used : Entry(java.util.Map.Entry) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) List(java.util.List) ArrayList(java.util.ArrayList) CCSinkResponder(logisticspipes.proxy.computers.objects.CCSinkResponder) Pair(logisticspipes.utils.tuples.Pair)

Example 58 with Entry

use of java.util.Map.Entry in project LogisticsPipes by RS485.

the class PipeItemsProviderLogistics method getAllItems.

@Override
public void getAllItems(Map<ItemIdentifier, Integer> items, List<IFilter> filters) {
    if (!isEnabled()) {
        return;
    }
    HashMap<ItemIdentifier, Integer> addedItems = new HashMap<>();
    WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(container);
    //@formatter:off
    Iterator<Map<ItemIdentifier, Integer>> iterator = worldCoordinates.getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).filter(adjacent -> adjacent.tileEntity instanceof IInventory).filter(adjacent -> !SimpleServiceLocator.pipeInformationManager.isItemPipe(adjacent.tileEntity)).map(adjacent -> getAdaptedInventoryUtil(adjacent).getItemsAndCount()).iterator();
    outer: while (iterator.hasNext()) {
        Iterator<Entry<ItemIdentifier, Integer>> entryIterator = iterator.next().entrySet().stream().filter(currentItem -> !items.containsKey(currentItem.getKey())).filter(currentItem -> !hasFilter() || (!isExcludeFilter() || !itemIsFiltered(currentItem.getKey())) && (isExcludeFilter() || itemIsFiltered(currentItem.getKey()))).iterator();
        while (entryIterator.hasNext()) {
            Entry<ItemIdentifier, Integer> next = entryIterator.next();
            for (IFilter filter : filters) {
                if (filter.isBlocked() == filter.isFilteredItem(next.getKey().getUndamaged()) || filter.blockProvider()) {
                    continue outer;
                }
            }
            Integer addedAmount = addedItems.get(next.getKey());
            if (addedAmount == null) {
                addedItems.put(next.getKey(), next.getValue());
            } else {
                addedItems.put(next.getKey(), addedAmount + next.getValue());
            }
        }
    }
    // reduce what has been reserved, add.
    for (Entry<ItemIdentifier, Integer> item : addedItems.entrySet()) {
        int remaining = item.getValue() - _orderManager.totalItemsCountInOrders(item.getKey());
        if (remaining < 1) {
            continue;
        }
        items.put(item.getKey(), remaining);
    }
}
Also used : IRouter(logisticspipes.routing.IRouter) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) Textures(logisticspipes.textures.Textures) Item(net.minecraft.item.Item) LogisticsPipes(logisticspipes.LogisticsPipes) ProviderPipeInclude(logisticspipes.network.packets.modules.ProviderPipeInclude) Particles(logisticspipes.pipefxhandlers.Particles) ChestContent(logisticspipes.network.packets.hud.ChestContent) MainProxy(logisticspipes.proxy.MainProxy) IHeadUpDisplayRenderer(logisticspipes.interfaces.IHeadUpDisplayRenderer) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) HUDStartWatchingPacket(logisticspipes.network.packets.hud.HUDStartWatchingPacket) SinkReply(logisticspipes.utils.SinkReply) SidedInventoryMinecraftAdapter(logisticspipes.utils.SidedInventoryMinecraftAdapter) Map(java.util.Map) ModuleProvider(logisticspipes.modules.ModuleProvider) IAdditionalTargetInformation(logisticspipes.interfaces.routing.IAdditionalTargetInformation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IChangeListener(logisticspipes.interfaces.IChangeListener) HUDStopWatchingPacket(logisticspipes.network.packets.hud.HUDStopWatchingPacket) IProvideItems(logisticspipes.interfaces.routing.IProvideItems) ConnectionPipeType(logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType) Collection(java.util.Collection) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) LogisticsManager(logisticspipes.logistics.LogisticsManager) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) Set(java.util.Set) PacketHandler(logisticspipes.network.PacketHandler) RequestTreeNode(logisticspipes.request.RequestTreeNode) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) DictResource(logisticspipes.request.resources.DictResource) Collectors(java.util.stream.Collectors) TransportMode(logisticspipes.logisticspipes.IRoutedItem.TransportMode) List(java.util.List) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) IChestContentReceiver(logisticspipes.interfaces.IChestContentReceiver) IFilter(logisticspipes.interfaces.routing.IFilter) OrdererManagerContent(logisticspipes.network.packets.orderer.OrdererManagerContent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) GuiIDs(logisticspipes.network.GuiIDs) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) ItemResource(logisticspipes.request.resources.ItemResource) LogisticsOrder(logisticspipes.routing.order.LogisticsOrder) HashMap(java.util.HashMap) HUDProvider(logisticspipes.gui.hud.HUDProvider) ResourceType(logisticspipes.routing.order.IOrderInfoProvider.ResourceType) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) IRequestItems(logisticspipes.interfaces.routing.IRequestItems) IHeadUpDisplayRendererProvider(logisticspipes.interfaces.IHeadUpDisplayRendererProvider) ExtractionMode(logisticspipes.logisticspipes.ExtractionMode) LogisticsItemOrderManager(logisticspipes.routing.order.LogisticsItemOrderManager) LinkedList(java.util.LinkedList) Iterator(java.util.Iterator) LogisticsItemOrder(logisticspipes.routing.order.LogisticsItemOrder) LogisticsPromise(logisticspipes.routing.LogisticsPromise) TextureType(logisticspipes.textures.Textures.TextureType) RequestTree(logisticspipes.request.RequestTree) AdjacentTileEntity(network.rs485.logisticspipes.world.WorldCoordinatesWrapper.AdjacentTileEntity) IResource(logisticspipes.request.resources.IResource) TreeMap(java.util.TreeMap) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ProviderPipeMode(logisticspipes.network.packets.modules.ProviderPipeMode) IInventory(net.minecraft.inventory.IInventory) IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) IOrderManagerContentReceiver(logisticspipes.interfaces.IOrderManagerContentReceiver) IInventory(net.minecraft.inventory.IInventory) HashMap(java.util.HashMap) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Entry(java.util.Map.Entry) IFilter(logisticspipes.interfaces.routing.IFilter) Iterator(java.util.Iterator) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 59 with Entry

use of java.util.Map.Entry in project che by eclipse.

the class DeletePackageFragmentRootChange method doDelete.

@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
    if (!confirmDeleteIfReferenced())
        return new NullChange();
    int resourceUpdateFlags = IResource.KEEP_HISTORY;
    int jCoreUpdateFlags = IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH | IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH;
    //$NON-NLS-1$
    pm.beginTask("", 2);
    IPackageFragmentRoot root = getRoot();
    IResource rootResource = root.getResource();
    CompositeChange result = new CompositeChange(getName());
    ResourceDescription rootDescription = ResourceDescription.fromResource(rootResource);
    IJavaProject[] referencingProjects = JavaElementUtil.getReferencingProjects(root);
    HashMap<IFile, String> classpathFilesContents = new HashMap<IFile, String>();
    for (int i = 0; i < referencingProjects.length; i++) {
        IJavaProject javaProject = referencingProjects[i];
        //$NON-NLS-1$
        IFile classpathFile = javaProject.getProject().getFile(".classpath");
        if (classpathFile.exists()) {
            classpathFilesContents.put(classpathFile, getFileContents(classpathFile));
        }
    }
    root.delete(resourceUpdateFlags, jCoreUpdateFlags, new SubProgressMonitor(pm, 1));
    rootDescription.recordStateFromHistory(rootResource, new SubProgressMonitor(pm, 1));
    for (Iterator<Entry<IFile, String>> iterator = classpathFilesContents.entrySet().iterator(); iterator.hasNext(); ) {
        Entry<IFile, String> entry = iterator.next();
        IFile file = entry.getKey();
        String contents = entry.getValue();
        //Restore time stamps? This should probably be some sort of UndoTextFileChange.
        TextFileChange classpathUndo = new TextFileChange(Messages.format(RefactoringCoreMessages.DeletePackageFragmentRootChange_restore_file, BasicElementLabels.getPathLabel(file.getFullPath(), true)), file);
        classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents));
        result.add(classpathUndo);
    }
    result.add(new UndoDeleteResourceChange(rootDescription));
    pm.done();
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Entry(java.util.Map.Entry) IJavaProject(org.eclipse.jdt.core.IJavaProject) NullChange(org.eclipse.ltk.core.refactoring.NullChange) ResourceDescription(org.eclipse.ui.ide.undo.ResourceDescription) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) IResource(org.eclipse.core.resources.IResource)

Example 60 with Entry

use of java.util.Map.Entry in project netty by netty.

the class Http2FrameCodecTest method connectionHandlerShouldBeAddedBeforeFramingHandler.

@Test
public void connectionHandlerShouldBeAddedBeforeFramingHandler() {
    Iterator<Entry<String, ChannelHandler>> iter = channel.pipeline().iterator();
    while (iter.hasNext()) {
        ChannelHandler handler = iter.next().getValue();
        if (handler instanceof Http2ConnectionHandler) {
            break;
        }
    }
    assertTrue(iter.hasNext());
    assertThat(iter.next().getValue(), instanceOf(Http2FrameCodec.class));
}
Also used : Entry(java.util.Map.Entry) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Aggregations

Entry (java.util.Map.Entry)2862 Map (java.util.Map)804 HashMap (java.util.HashMap)786 ArrayList (java.util.ArrayList)749 List (java.util.List)579 IOException (java.io.IOException)314 Iterator (java.util.Iterator)311 Test (org.junit.Test)308 Set (java.util.Set)294 HashSet (java.util.HashSet)271 LinkedHashMap (java.util.LinkedHashMap)194 Collection (java.util.Collection)186 Collectors (java.util.stream.Collectors)179 File (java.io.File)146 TreeMap (java.util.TreeMap)125 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)114 Key (org.apache.accumulo.core.data.Key)112 Value (org.apache.accumulo.core.data.Value)111 Collections (java.util.Collections)104 LinkedList (java.util.LinkedList)103