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:com.pavikumbhar.javaheart.util.PasswordGenerator.java

private String generatePassword(int length) {
    int count = c.length;
    LinkedList<Character> s = new LinkedList<Character>();
    LinkedList<Character> s1 = new LinkedList<Character>();
    Collections.addAll(s, c);/*from  ww w  .  j a  va  2s.  c  om*/
    while (count > 0) {
        long n = generateRandomNumber();
        int position = (int) (n % count);
        s1.add(s.remove(position));
        count--;
    }
    String pwd = null;
    //System.out.println(">>"+s1.toString()); 
    Character[] c1 = new Character[s1.size()];
    c1 = s1.toArray(c1);
    String s2 = new String(f1(c1));
    //System.out.println(">>"+s2); 

    return RandomStringUtils.random(length, s2);

}

From source file:de.devmil.common.ui.color.HistorySelectorView.java

public JSONArray moveValueToFront(JSONArray array, int index, int color) throws JSONException {
    LinkedList<Integer> list = new LinkedList<Integer>();
    for (int i = 0; i < array.length(); i++) {
        list.add(array.getInt(i));//from  w  ww .  j a  v  a 2 s .  c o m
    }

    list.add(color);
    list.remove(index);

    array = new JSONArray();
    for (int i : list) {
        array.put(i);
    }

    return array;
}

From source file:com.stimulus.archiva.domain.EmailFilter.java

public void setPriority(int id, Priority priority) {
    LinkedList<FilterRule> list = filterRules;
    FilterRule ar = filterRules.get(id);
    list.remove(ar);

    switch (priority) {
    case HIGHER://from   ww w .ja  va  2 s . c  o m
        if ((id - 1) <= 0)
            list.addFirst(ar);
        else
            list.add(id - 1, ar);
        break;
    case LOWER:
        if ((id + 1) >= list.size())
            list.addLast(ar);
        else
            list.add(id + 1, ar);
        break;
    case HIGHEST:
        list.addFirst(ar);
        break;
    case LOWEST:
        list.addLast(ar);
        break;
    }
}

From source file:com.google.blockly.android.codegen.CodeGeneratorService.java

private boolean equivalentLists(List<String> newDefinitions, List<String> oldDefinitions) {
    LinkedList<String> checkList = new LinkedList<>(oldDefinitions);
    for (String filename : newDefinitions) {
        if (!checkList.remove(filename)) {
            return false;
        }/* w ww .  ja  v a  2s .  c  o  m*/
    }
    return checkList.isEmpty(); // If it is empty, all filenames were found / matched.
}

From source file:pl.reticular.ttw.game.model.Spider.java

private Pair<Particle, Spring> nextTargetAtRandom() {

    LinkedList<Edge> list = new LinkedList<>(target.getEdges());
    if (list.size() > 1) {
        list.remove(spring);
    }//from w w  w.ja v  a2  s  .  c  om
    int i = generator.nextInt(list.size());
    Spring nextSpring = (Spring) list.get(i);

    if (nextSpring.getParticle1() == target) {
        return new Pair<>(nextSpring.getParticle2(), nextSpring);
    } else {
        return new Pair<>(nextSpring.getParticle1(), nextSpring);
    }
}

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

@Override
public void deleteEvent(EventoVB ev) {
    int n = javax.swing.JOptionPane.showConfirmDialog(mainFrame, "Borrar Evento?", "Confirmacin",
            javax.swing.JOptionPane.YES_NO_OPTION);
    if (n == javax.swing.JOptionPane.YES_OPTION) {
        LinkedList<EventoVB> value = new LinkedList<>();
        for (EventoVB x : this.modelo) {
            value.add(x);/*from   ww  w.j  av a2s  . c  o m*/
        }
        value.remove(ev);
        actualizaModelo(value);
    }
}

From source file:WaitSemaphore.java

protected void logRelease() {
    if (m_debug) {
        // Find a matching thread and remove info for it
        Thread thread = Thread.currentThread();

        LinkedList list = (LinkedList) m_logMap.get(thread);
        if (list != null) {
            Info info = new Info(thread, 0, "");
            if (!list.remove(info)) {
                System.err.println("LOG INFO SIZE: " + list);
                new IllegalStateException("BUG: semaphore log list does not contain required info")
                        .printStackTrace();
            }// w w  w.ja  v  a  2s .  c o  m

            // If no info left, remove the mapping
            int size = list.size();
            if (size < 1) {
                m_logMap.remove(thread);
            }
        } else {
            throw new IllegalStateException("Semaphore log failed: release called without acquire");
        }
    }
}

From source file:org.duracloud.account.app.controller.AccountGroupsController.java

private Collection<DuracloudUser> getAvailableUsers(AccountService as, Collection<DuracloudUser> groupUsers) {
    Set<DuracloudUser> allUsers = as.getUsers();
    LinkedList<DuracloudUser> list = new LinkedList<DuracloudUser>();
    list.addAll(allUsers);/*  ww  w  . j ava2 s  .  c  o  m*/
    for (DuracloudUser user : allUsers) {
        if (user.isRoot()) {
            list.remove(user);
        }
    }

    if (groupUsers != null) {
        list.removeAll(groupUsers);
    }

    Collections.sort(list, USERNAME_COMPARATOR);
    return list;
}

From source file:eu.stratosphere.nephele.multicast.MulticastManager.java

/**
 * Returns and removes the TreeNode which is closest to the given indicator.
 * /*w ww .  jav a2  s . c o m*/
 * @param indicator
 * @param nodes
 * @return
 */
private TreeNode pollClosestNode(final TreeNode indicator, final LinkedList<TreeNode> nodes) {

    TreeNode closestnode = getClosestNode(indicator, nodes);

    nodes.remove(closestnode);

    return closestnode;

}