Example usage for java.util LinkedList contains

List of usage examples for java.util LinkedList contains

Introduction

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

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:es.emergya.bbdd.dao.PatrullaHome.java

public Patrulla[] getAsigned(Incidencia i) {
    Recurso[] recursos = RecursoConsultas.getAsigned(i);
    LinkedList<Patrulla> res = new LinkedList<Patrulla>();
    for (Recurso rec : recursos)
        if (!res.contains(rec.getPatrullas()))
            res.add(rec.getPatrullas());
    return res.toArray(new Patrulla[0]);
}

From source file:com.alibaba.jstorm.ui.utils.UIUtils.java

private static int bfsDepth(List<TreeNode> roots) {
    LinkedList<TreeNode> queue = Lists.newLinkedList();
    for (TreeNode root : roots) {
        root.setLayer(0);//  ww  w . ja v a 2 s.  c o  m
        queue.push(root);
    }

    int depth = 0;
    while (!queue.isEmpty()) {
        TreeNode cur = queue.poll();
        if (cur.getLayer() > depth) {
            depth = cur.getLayer();
        }
        for (TreeNode n : cur.getChildren()) {

            int newLayer = cur.getLayer() + 1;
            if (!n.isVisited() || n.getLayer() < newLayer) {
                if (!n.inCircle(cur)) {
                    //n and cur is not in loop
                    n.setLayer(newLayer);
                    if (!queue.contains(n)) {
                        queue.push(n);
                    }
                } else if (n.addLoopNode(cur)) {
                    // loop nodes only set layer once.
                    n.setLayer(newLayer);
                }
            }

        }
    }
    return depth;
}

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

@Override
public void updateModel(Object origen, String property, Object value) {
    if (!ignore.remove(value)) {
        LinkedList<EventoVB> param = (LinkedList<EventoVB>) value;
        LinkedList<EventoVB> borrar = new LinkedList<>();
        for (EventoVB obj : modelo) {
            if (!param.contains(obj)) {
                borrar.add(obj);/*  w ww . jav  a2  s. c  o  m*/
            }
        }
        for (EventoVB x : borrar) {
            removeEvento(x);
        }
        for (int i = 0; i < param.size(); i++) {
            if (this.modelo.size() > i) {
                if (!param.get(i).equals(this.modelo.get(i))) {
                    this.modelo.add(i, param.get(i));
                    addEventoView(this.modelo.get(i), i);
                }
            } else {
                this.modelo.add(param.get(i));
                addEventoView(this.modelo.get(i), i);
            }
        }
        this.updateUI();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                jScrollPane1.getVerticalScrollBar().setValue(jScrollPane1.getVerticalScrollBar().getMaximum());
            }
        });
    }
}

From source file:marytts.modules.ModuleRegistry.java

/**
 * This method recursively calls itself.
 * It forward-constructs a list of seen types (upon test),
 * and backward-constructs a list of required modules (upon success).
 *
 * @param sourceType/*  w  w w. ja va 2  s  .  co m*/
 * @param targetType
 * @param locale
 * @param voice
 * @param seenTypes
 * @return
 */
private static LinkedList<MaryModule> modulesRequiredForProcessing(MaryDataType sourceType,
        MaryDataType targetType, Locale locale, Voice voice, LinkedList<MaryDataType> seenTypes) {
    // Terminating condition:
    if (sourceType.equals(targetType)) {
        logger.debug("found path through modules");
        return new LinkedList<MaryModule>();
    }
    // Recursion step:
    // Any voice-specific modules?
    List<MaryModule> candidates = null;
    // TODO: the following should be obsolete as soon as we are properly using the voice index in ModuleRegistry
    if (voice != null)
        candidates = voice.getPreferredModulesAcceptingType(sourceType);
    if (candidates == null || candidates.isEmpty()) { // default: use all available modules
        candidates = get(sourceType, locale, voice);
    }
    if (candidates == null || candidates.isEmpty()) {
        // no module can handle this type
        return null;
    }
    for (Iterator<MaryModule> it = candidates.iterator(); it.hasNext();) {
        MaryModule candidate = it.next();
        MaryDataType outputType = candidate.outputType();
        // Ignore candidates that would bring us to a data type that we
        // have already seen (i.e., that would lead to a loop):
        if (!seenTypes.contains(outputType)) {
            seenTypes.add(outputType);
            logger.debug("Module " + candidate.name() + " converts " + sourceType.name() + " into " + outputType
                    + " (locale " + locale + ", voice " + voice + ")");
            // recursive call:
            LinkedList<MaryModule> path = modulesRequiredForProcessing(outputType, targetType, locale, voice,
                    seenTypes);
            if (path != null) {
                // success, found a path of which candidate is the first
                // step
                path.addFirst(candidate);
                return path;
            } // else, try next candidate
            seenTypes.removeLast();
        }
    }
    // We get here only if none of the candidates lead to a valid path
    return null; // failure
}

From source file:com.bluros.updater.service.UpdateCheckService.java

@Override
public void onResponse(JSONObject jsonObject) {
    int updateType = Utils.getUpdateType();

    LinkedList<UpdateInfo> lastUpdates = State.loadState(this);
    LinkedList<UpdateInfo> updates = parseJSON(jsonObject.toString(), updateType);

    int newUpdates = 0, realUpdates = 0;
    for (UpdateInfo ui : updates) {
        if (!lastUpdates.contains(ui)) {
            newUpdates++;/*from   w w  w.  ja  v  a 2s  . co  m*/
        }
        if (ui.isNewerThanInstalled()) {
            realUpdates++;
        }
    }

    Intent intent = new Intent(ACTION_CHECK_FINISHED);
    intent.putExtra(EXTRA_UPDATE_COUNT, updates.size());
    intent.putExtra(EXTRA_REAL_UPDATE_COUNT, realUpdates);
    intent.putExtra(EXTRA_NEW_UPDATE_COUNT, newUpdates);

    recordAvailableUpdates(updates, intent);
    State.saveState(this, updates);
}

From source file:com.frostwire.platform.FileSystemWalkTest.java

@Test
public void testDir() throws IOException {
    File f1 = File.createTempFile("aaa", null);
    File d1 = f1.getParentFile();
    final File d2 = new File(d1, "d2");
    if (d2.exists()) {
        FileUtils.deleteDirectory(d2);/* www  . jav  a  2s  .  c o  m*/
    }
    assertTrue(d2.mkdir());
    File f2 = new File(d2, "bbb");
    assertTrue(f2.createNewFile());

    final LinkedList<File> l = new LinkedList<>();

    fs.walk(d1, new FileFilter() {
        @Override
        public boolean accept(File file) {
            return true;
        }

        @Override
        public void file(File file) {
            l.add(file);
        }
    });

    Set<File> set = new LinkedHashSet<>(l);
    assertEquals(set.size(), l.size());

    assertFalse(l.contains(d1));
    assertTrue(l.contains(f1));
    assertTrue(l.contains(d2));
    assertTrue(l.contains(f2));

    l.clear();
    fs.walk(d1, new FileFilter() {
        @Override
        public boolean accept(File file) {
            return !file.equals(d2);
        }

        @Override
        public void file(File file) {
            l.add(file);
        }
    });

    assertFalse(l.contains(d1));
    assertTrue(l.contains(f1));
    assertFalse(l.contains(d2));
    assertFalse(l.contains(f2));

    assertTrue(f2.delete());
    assertTrue(d2.delete());
    assertTrue(f1.delete());
}

From source file:de.quadrillenschule.azocamsyncd.ftpservice.FTPConnection.java

public LinkedList<AZoFTPFile> discoverRemoteFiles(String root, boolean includeDirs) throws IOException {
    LinkedList<AZoFTPFile> retval = new LinkedList();
    for (FTPFile f : ftpclient.listFiles(root)) {

        AZoFTPFile af = new AZoFTPFile(f, root);
        if (f.isFile() && isPicture(af) && !retval.contains(af)) {
            retval.add(af);//from   w w  w  .j a v  a2 s  .  c  o m
        }
        if (f.isDirectory()) {
            if (includeDirs) {
                retval.add(af);
            }

            retval.addAll(discoverRemoteFiles(root + f.getName() + "/", includeDirs));
        }
    }
    return retval;

}

From source file:com.norman0406.slimgress.FragmentInventory.java

void fillPortalKeys() {
    Inventory inv = mGame.getInventory();

    int count = 0;
    List<ItemBase> items = inv.getItems(ItemType.PortalKey);
    count += items.size();/*w w w.j  a v  a2  s.  c o m*/

    LinkedList<ItemPortalKey> skipItems = new LinkedList<ItemPortalKey>();
    for (ItemBase item1 : items) {
        ItemPortalKey theItem1 = (ItemPortalKey) item1;

        // skip items that have already been checked
        if (skipItems.contains(theItem1))
            continue;

        String descr = theItem1.getPortalTitle();

        // check for multiple portal keys with the same portal guid
        int itemCount = 1;
        for (ItemBase item2 : items) {
            ItemPortalKey theItem2 = (ItemPortalKey) item2;

            // don't check the doubles
            if (theItem2 == theItem1)
                continue;

            if (theItem1.getPortalGuid().equals(theItem2.getPortalGuid())) {
                itemCount++;
                skipItems.add(theItem2);
            }
        }

        if (itemCount > 1)
            descr += " (" + itemCount + ")";
        mGroupPortalKeys.add(descr);
    }
    mGroupNames.add("PortalKeys (" + count + ")");
    mGroups.add(mGroupPortalKeys);
}

From source file:com.norman0406.slimgress.FragmentInventory.java

void fillMedia() {
    Inventory inv = mGame.getInventory();

    int count = 0;
    for (int level = 1; level <= 8; level++) {
        List<ItemBase> items = inv.getItems(ItemType.Media, level);
        count += items.size();// w  w  w.j  av  a  2s . co m

        LinkedList<ItemMedia> skipItems = new LinkedList<ItemMedia>();
        for (ItemBase item1 : items) {
            ItemMedia theItem1 = (ItemMedia) item1;

            // skip items that have already been checked
            if (skipItems.contains(theItem1))
                continue;

            String descr = "L" + level + " " + theItem1.getMediaDescription();

            // check for multiple media items with the same description
            int itemCount = 1;
            for (ItemBase item2 : items) {
                ItemMedia theItem2 = (ItemMedia) item2;

                // don't check the doubles
                if (theItem2 == theItem1)
                    continue;

                if (theItem1.getMediaDescription().equals(theItem2.getMediaDescription())) {
                    itemCount++;
                    skipItems.add(theItem2);
                }
            }

            if (!theItem1.getMediaHasBeenViewed())
                descr += " [NEW]";

            if (itemCount > 1)
                descr += " (" + itemCount + ")";
            mGroupMedia.add(descr);
        }
    }
    mGroupNames.add("Media (" + count + ")");
    mGroups.add(mGroupMedia);
}

From source file:util.method.java

public static LinkedList<String> addUnRepeatedValueToList(String valueToAdd, LinkedList<String> listToAdd) {
    if (!listToAdd.contains(valueToAdd))
        listToAdd.add(valueToAdd);//from ww w  .j av a  2s . c o  m

    return listToAdd;

}