Example usage for java.util LinkedList remove

List of usage examples for java.util LinkedList remove

Introduction

In this page you can find the example usage for java.util LinkedList remove.

Prototype

public E remove(int index) 

Source Link

Document

Removes the element at the specified position in this list.

Usage

From source file:org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry.java

private void unregisterMouseBinding(MouseEventTypeEnum mouseEventType, IMouseEventMatcher mouseEventMatcher) {
    LinkedList<MouseBinding> mouseBindings = this.mouseBindingsMap.get(mouseEventType);
    if (mouseBindings != null) {
        for (MouseBinding mouseBinding : mouseBindings) {
            if (mouseBinding.getMouseEventMatcher().equals(mouseEventMatcher)) {
                mouseBindings.remove(mouseBinding);
                return;
            }/*from  ww w .jav  a  2  s. c  o  m*/
        }
    }
}

From source file:ubic.gemma.datastructure.matrix.ExpressionDataMatrixColumnSort.java

/**
 * Sort biomaterials according to a list of ordered factors
 * // w  w w . j ava2  s . co  m
 * @param start biomaterials to sort
 * @param factorsToUse sorted list of factors to define sort order for biomaterials, cannot be null
 * @return
 */
public static List<BioMaterial> orderBiomaterialsBySortedFactors(List<BioMaterial> start,
        List<ExperimentalFactor> factors) {

    if (start.size() == 1) {
        return start;
    }

    if (start.size() == 0) {
        throw new IllegalArgumentException("Must provide some biomaterials");
    }
    if (factors == null) {
        throw new IllegalArgumentException("Must provide sorted factors, or at least an empty list");
    }
    if (factors.isEmpty()) {
        // we're done.
        return start;
    }

    ExperimentalFactor simplest = factors.get(0);

    if (simplest == null) {
        // we're done.
        return start;
    }

    /*
     * Order this chunk by the selected factor
     */

    Map<FactorValue, List<BioMaterial>> fv2bms = buildFv2BmMap(start);
    List<BioMaterial> ordered = orderByFactor(simplest, fv2bms, start,
            new HashMap<ExperimentalFactor, Collection<BioMaterial>>());

    LinkedList<ExperimentalFactor> factorsStillToDo = new LinkedList<ExperimentalFactor>();
    factorsStillToDo.addAll(factors);
    factorsStillToDo.remove(simplest);

    if (factorsStillToDo.size() == 0) {
        /*
         * No more ordering is necessary.
         */
        return ordered;
    }

    log.debug("Factors: " + factors.size());

    /*
     * Recurse in and order each chunk. First split it up, but retaining the order we just made.
     */
    LinkedHashMap<FactorValue, List<BioMaterial>> chunks = chunkOnFactor(simplest, ordered);

    if (chunks == null) {
        // this means we should bail, gracefully.
        return start;
    }

    /*
     * Process each chunk.
     */
    List<BioMaterial> result = new ArrayList<BioMaterial>();
    for (FactorValue fv : chunks.keySet()) {
        List<BioMaterial> chunk = chunks.get(fv);

        if (chunk.size() < 2) {
            result.addAll(chunk);
        } else {
            List<BioMaterial> orderedChunk = orderBiomaterialsBySortedFactors(chunk, factorsStillToDo);
            result.addAll(orderedChunk);
        }
    }

    return result;

}

From source file:ubic.gemma.datastructure.matrix.ExpressionDataMatrixColumnSort.java

/**
 * Sort biomaterials according to a list of ordered factors
 * //from   w  w  w .j  a  v  a  2s.c om
 * @param start biomaterials to sort
 * @param factorsToUse sorted list of factors to define sort order for biomaterials, cannot be null
 * @return
 */
public static List<BioMaterialValueObject> orderBiomaterialsBySortedFactorsVO(
        List<BioMaterialValueObject> start, List<ExperimentalFactor> factors) {

    if (start.size() == 1) {
        return start;
    }

    if (start.size() == 0) {
        throw new IllegalArgumentException("Must provide some biomaterials");
    }
    if (factors == null) {
        throw new IllegalArgumentException("Must provide sorted factors, or at least an empty list");
    }
    if (factors.isEmpty()) {
        // we're done.
        return start;
    }

    ExperimentalFactor simplest = factors.get(0);

    if (simplest == null) {
        // we're done.
        return start;
    }

    /*
     * Order this chunk by the selected factor
     */

    Map<FactorValueValueObject, List<BioMaterialValueObject>> fv2bms = buildFv2BmVOMap(start);
    List<BioMaterialValueObject> ordered = orderByFactorVo(simplest, fv2bms, start,
            new HashMap<ExperimentalFactor, Collection<BioMaterialValueObject>>());

    LinkedList<ExperimentalFactor> factorsStillToDo = new LinkedList<ExperimentalFactor>();
    factorsStillToDo.addAll(factors);
    factorsStillToDo.remove(simplest);

    if (factorsStillToDo.size() == 0) {
        /*
         * No more ordering is necessary.
         */
        return ordered;
    }

    log.debug("Factors: " + factors.size());

    /*
     * Recurse in and order each chunk. First split it up, but retaining the order we just made.
     */
    LinkedHashMap<FactorValueValueObject, List<BioMaterialValueObject>> chunks = chunkOnFactorVO(simplest,
            ordered);

    if (chunks == null) {
        // this means we should bail, gracefully.
        return start;
    }

    /*
     * Process each chunk.
     */
    List<BioMaterialValueObject> result = new ArrayList<BioMaterialValueObject>();
    for (FactorValueValueObject fv : chunks.keySet()) {
        List<BioMaterialValueObject> chunk = chunks.get(fv);

        if (chunk.size() < 2) {
            result.addAll(chunk);
        } else {
            List<BioMaterialValueObject> orderedChunk = orderBiomaterialsBySortedFactorsVO(chunk,
                    factorsStillToDo);
            result.addAll(orderedChunk);
        }
    }

    return result;

}

From source file:m.c.m.proxyma.context.ProxymaContext.java

/**
 * Updates Context Destination Indexes.<br/>
 * This method is invoked from a proxy folder that has changed its
 * destination in order to keep aligned the internal index of the
 * registered proxy folders.//www . ja va 2 s .  c o  m
 *
 * @param theFolder the folder that has jus been updated
 */
protected void updateFolderDestinationIndex(URL oldDestination, ProxyFolderBean theFolder) {
    //Remove the proxy-folder from the second indexing map.
    String destinationHost = URLUtils.getDestinationHost(oldDestination);
    LinkedList<ProxyFolderBean> currentSlot = null;
    currentSlot = proxyFoldersByDestinationHost.get(destinationHost);
    if (currentSlot.size() == 1) {
        currentSlot.remove(theFolder);
        proxyFoldersByDestinationHost.remove(destinationHost);
    } else {
        Iterator<ProxyFolderBean> iterator = currentSlot.iterator();
        while (iterator.hasNext()) {
            ProxyFolderBean curFolder = iterator.next();
            if (curFolder == theFolder)
                iterator.remove();
        }
    }

    //Re-Add the proxy folder with the new destination host
    destinationHost = URLUtils.getDestinationHost(theFolder.getDestinationAsURL());
    currentSlot = null;
    if (proxyFoldersByDestinationHost.containsKey(destinationHost)) {
        currentSlot = proxyFoldersByDestinationHost.get(destinationHost);
        currentSlot.add(theFolder);
    } else {
        currentSlot = new LinkedList();
        currentSlot.add(theFolder);
        proxyFoldersByDestinationHost.put(destinationHost, currentSlot);
    }
}

From source file:eu.uqasar.model.tree.TreeNode.java

@JsonIgnore
private List<TreeNode> getMutableSiblings(boolean includeSelf) {
    if (this instanceof Project) {
        // TODO not sure if projects cannot have siblings!
        LinkedList<TreeNode> list = new LinkedList<>();
        if (includeSelf) {
            list.add(this);
        }//from   ww  w . ja  v a2  s.com
        return list;
    } else {
        if (includeSelf) {
            return getParent().getChildren();
        } else {
            LinkedList<TreeNode> siblings = (LinkedList<TreeNode>) getParent().getChildren().clone();
            siblings.remove(this);
            return siblings;
        }
    }
}

From source file:org.nekorp.workflow.desktop.view.CobranzaView.java

@Override
public void deletePago(PagoCobranzaVB ev) {
    int n = javax.swing.JOptionPane.showConfirmDialog(mainFrame, "Borrar Pago?", "Confirmacin",
            javax.swing.JOptionPane.YES_NO_OPTION);
    if (n == javax.swing.JOptionPane.YES_OPTION) {
        LinkedList<PagoCobranzaVB> value = new LinkedList<>();
        for (PagoCobranzaVB x : this.modelo) {
            value.add(x);//  w  w w. ja va  2  s  .  c om
        }
        value.remove(ev);
        actualizaModelo(value);
    }
}

From source file:com.btobits.automator.fix.ant.task.FixFieldTask.java

private void setField(final LinkedList<FixMessageType.Field> fields) {
    for (final FixMessageType.Field f : fields) {
        int id1 = FixUtils.getFieldId(f.getName());
        int id2 = FixUtils.getFieldId(name);
        if (id1 == id2) {
            fields.remove(f);
            break;
        }//from   ww  w  . j av a  2  s .  c  om
    }

    final String fieldValue = StringUtils.isNotBlank(value) ? value
            : StringUtils.isNotBlank(property) ? getProject().getProperty(property) : null;

    if (StringUtils.isNotBlank(fieldValue)) {
        final FixMessageType.Field field = new FixMessageType.Field();
        field.setName(name);
        field.setValue(fieldValue);
        fields.add(field);
    }
}

From source file:m.c.m.proxyma.context.ProxymaContext.java

/**
 * Remove a ProxyFolder from the context
 * @param proxyFolder the proxyFolder to remove.
 * @throws IllegalArgumentException if the context doesn't exist
 * @throws NullArgumentException if the argument is null
 *//*from  w w w.  ja  va 2  s .  c  om*/
public void removeProxyFolder(ProxyFolderBean proxyFolder)
        throws IllegalArgumentException, NullArgumentException {
    if (proxyFolder == null) {
        log.warning("Null ProxyFolderBean parameter.. Ignoring operation");
        throw new NullArgumentException("Null ProxyFolderBean parameter.. Ignoring operation");
    } else {
        boolean exists = proxyFoldersByURLEncodedName.containsKey(proxyFolder.getURLEncodedFolderName());
        if (!exists) {
            log.warning("The Proxy foder doesn't exists.. nothing done.");
            throw new IllegalArgumentException("The Proxy foder doesn't exists.. nothing done.");
        } else {
            log.finer("Deleting existing Proxy folder " + proxyFolder.getFolderName());
            proxyFoldersByURLEncodedName.remove(proxyFolder.getURLEncodedFolderName());

            //Delete the proxy-folder from the second indexing map.
            String destinationHost = URLUtils.getDestinationHost(proxyFolder.getDestinationAsURL());
            LinkedList<ProxyFolderBean> currentSlot = null;
            currentSlot = proxyFoldersByDestinationHost.get(destinationHost);
            if (currentSlot.size() == 1) {
                currentSlot.remove(proxyFolder);
                proxyFoldersByDestinationHost.remove(destinationHost);
            } else {
                Iterator<ProxyFolderBean> iterator = currentSlot.iterator();
                while (iterator.hasNext()) {
                    ProxyFolderBean curFolder = iterator.next();
                    if (curFolder == proxyFolder)
                        iterator.remove();
                }
            }
        }
    }
}

From source file:io.mapzone.controller.vm.provisions.MaxProcesses.java

@Override
public Status execute() throws Exception {
    checked.set(this);
    assert process
            .isPresent() : "No process in context. Make sure that MaxProcesses executes after ProcessStarted.";

    HostRecord host = process.get().instance.get().host.get();
    if (host.statistics.get() == null || host.statistics.get().olderThan(10, TimeUnit.SECONDS)) {

        host.updateStatistics();/*from  www .  j a va  2 s . com*/

        // lowest start time (oldest) first
        LinkedList<ProcessRecord> sortedProcesses = host.instances.stream().filter(i -> i.process.get() != null)
                .map(i -> i.process.get()).sorted((p1, p2) -> p1.started.get().compareTo(p2.started.get()))
                .collect(Collectors.toCollection(LinkedList::new));
        log.info("    PROCESSES RUNNING: " + sortedProcesses.size() + " ("
                + host.statistics.get().lastChecked.get() + ")");

        // stop processes, oldest first
        while (sortedProcesses.size() > MAX_PROCESSES) {
            ProcessRecord p = sortedProcesses.remove(0);

            log.info("    stopping process: " + p.instance.get().project.get() + " -- started at "
                    + p.started.get());
            StopProcessOperation op = new StopProcessOperation();
            op.process.set(p);
            op.vmUow.set(vmUow());
            op.execute(null, null);
        }
    }

    return OK_STATUS;
}

From source file:eu.uqasar.model.qmtree.QMTreeNode.java

@SuppressWarnings("unchecked")
@Override//from w ww.  j a va 2 s. com
public boolean changePositionWithPreviousSibling(boolean changeParents) {
    LinkedList<QMTreeNode> directSiblings = (LinkedList<QMTreeNode>) getMutableSiblings();
    int currentIndex = directSiblings.indexOf(this);
    int newIndex = currentIndex - 1;
    if (currentIndex > 0) {
        // switch currently selected node with the previous one
        QMTreeNode movedNode = directSiblings.remove(currentIndex);
        directSiblings.add(newIndex, movedNode);
        getParent().setChildren(directSiblings);
        logger.info(String.format("Moving %s from index %s to %s", this, currentIndex, newIndex));
        return true;
    } else if (currentIndex == 0 && changeParents) {
        // add currently selected node as last entry to the previous
        // parent sibling
        LinkedList<QMTreeNode> parentSiblings = (LinkedList<QMTreeNode>) this.getParent().getMutableSiblings();
        int parentIndex = parentSiblings.indexOf(this.getParent());
        int newParentIndex = parentIndex - 1;
        if (parentIndex > 0) {
            QMTreeNode oldParent = this.getParent();
            LinkedList<QMTreeNode> oldParentChildren = (LinkedList) oldParent.getChildren();
            oldParentChildren.remove(0);
            oldParent.setChildren(oldParentChildren);

            QMTreeNode newParent = parentSiblings.get(newParentIndex);
            logger.info(String.format("Moving %s from parent %s to %s", this, this.getParent(), newParent));
            this.setParent(newParent);
            return true;
        }
    }
    return false;
}