Example usage for java.util LinkedList get

List of usage examples for java.util LinkedList get

Introduction

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

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:pl.otros.logview.gui.message.StackTraceFinder.java

public SortedSet<SubText> findStackTraces(String text) {
    SortedSet<SubText> set = new TreeSet<SubText>();
    LinkedList<Integer> newLineIndexes = new LinkedList<Integer>();
    newLineIndexes.add(0);//  w  ww. j ava 2  s .  c  o m
    int newLineIndex = -1;
    while ((newLineIndex = StringUtils.indexOf(text, '\n', newLineIndex + 1)) > -1) {
        newLineIndexes.addLast(newLineIndex);
    }
    if (newLineIndexes.getLast() < text.length()) {
        newLineIndexes.addLast(text.length());
    }

    int startLine;
    int endLine;
    boolean found = false;
    int startedLineException = -1;
    for (int i = 0; i < newLineIndexes.size() - 1; i++) {
        startLine = newLineIndexes.get(i);
        endLine = newLineIndexes.get(i + 1);
        String line = text.substring(startLine, endLine);
        Matcher matcher = exceptionLine.matcher(line);
        boolean f = matcher.find();
        if (f && !found) {
            startedLineException = i - 1;
        } else if (!f && found) {
            // exception end
            int start = newLineIndexes.get(startedLineException);
            int end = newLineIndexes.get(i);
            SubText subText = new SubText(start, end);
            set.add(subText);
        }
        found = f;
    }
    // Add stacktrace if string with end of stacktrace
    if (found) {
        int start = newLineIndexes.get(startedLineException);
        int end = newLineIndexes.getLast();
        SubText subText = new SubText(start, end);
        set.add(subText);
    }
    // for (SubText subText : set) {
    // System.out.printf("[%d -> %d] \n\"%s\"", subText.start, subText.end, text.substring(subText.start, subText.end));
    // }
    return set;
}

From source file:org.springframework.ldap.support.LdapUtilsTest.java

@Test
public void testCollectAttributeValues() {
    String expectedAttributeName = "someAttribute";
    BasicAttribute expectedAttribute = new BasicAttribute(expectedAttributeName);
    expectedAttribute.add("value1");
    expectedAttribute.add("value2");

    BasicAttributes attributes = new BasicAttributes();
    attributes.put(expectedAttribute);/*from w  ww  .j a  v  a  2 s .co  m*/

    LinkedList list = new LinkedList();
    LdapUtils.collectAttributeValues(attributes, expectedAttributeName, list);

    assertThat(list).hasSize(2);
    assertThat(list.get(0)).isEqualTo("value1");
    assertThat(list.get(1)).isEqualTo("value2");
}

From source file:util.method.java

public static void printLinkedList(LinkedList list)

{

    for (int i = 0; i < list.size(); i++) {
        System.out.print(list.get(i));
    }/*from   w w  w . j a  va  2s .c om*/
}

From source file:ldbc.snb.datagen.generator.BTERKnowsGenerator.java

private void generateRemainingEdges() {
    LinkedList<Integer> stubs = new LinkedList<Integer>();
    for (int i = 0; i < graphSize; ++i) {
        long difference = expectedDegree[i] - adjacencyMatrix[i].getCardinality();
        if (difference > 0) {
            for (int j = 0; j < difference; ++j) {
                stubs.add(i);/*from  w  w w.j  a  va  2  s  . c o m*/
            }
        }
    }
    Collections.shuffle(stubs, random);
    while (!stubs.isEmpty()) {
        int node1 = stubs.get(0);
        stubs.remove(0);
        if (!stubs.isEmpty()) {
            int node2 = stubs.get(0);
            stubs.remove(0);
            if (node1 != node2) {
                adjacencyMatrix[node1].add(node2);
                adjacencyMatrix[node2].add(node1);
            }
        }
    }
}

From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java

private boolean confirmDelete(LinkedList<File> overlayFiles) {
    String confirmationText = I18N.getString("ManageOverlays.dialog.delete.confirmation");

    if (overlayFiles.isEmpty())
        return false;
    else if (overlayFiles.size() == 1) {
        confirmationText += overlayFiles.get(0).getName() + "?";
    } else {// w  w  w.ja  v a  2s  . c o m
        confirmationText += I18N.getString("ManageOverlays.dialog.delete.confirmation.these")
                + overlayFiles.size() + I18N.getString("ManageOverlays.dialog.delete.confirmation.overlays");
    }

    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(I18N.getString("ManageOverlays.dialog.delete.title"));
    alert.setContentText(confirmationText);

    Optional<ButtonType> result = alert.showAndWait();

    if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
        return true;
    }

    return false;
}

From source file:com.sun.portal.rssportlet.SettingsHandler.java

private LinkedList fileterFeeds(SettingsBean delta, String[] feedFilter) {
    LinkedList feeds = delta.getFeeds();
    if (null != feedFilter && feedFilter.length != 0) {
        for (int i = 0; i < feedFilter.length; i++) {
            for (int j = 0; j < delta.getFeedsSize(); j++) {
                if (((String) feeds.get(j)).equalsIgnoreCase(feedFilter[i])) {
                    feeds.remove(j);/* ww  w  .  j ava 2 s  .c  o m*/
                    break;
                }
            }
        }
    }
    return feeds;
}

From source file:util.method.java

public static VM findVMByIDFromVMList(LinkedList<VM> VMList, String VMID) {

    for (int i = 0; i < VMList.size(); i++) {
        VM currentVM = VMList.get(i);
        if (currentVM.getID().equals(VMID))
            return currentVM;
    }// www  .  j ava  2s  . com

    return null;

}

From source file:com.addthis.hydra.data.query.QueryElementNode.java

public Iterator<DataTreeNode> getNodes(LinkedList<DataTreeNode> stack) {
    List<DataTreeNode> ret = null;
    if (up()) {//w  w  w  .  j  a v  a2  s.co  m
        ret = new ArrayList<>(1);
        ret.add(stack.get(1));
        return ret.iterator();
    }
    DataTreeNode parent = stack.peek();
    DataTreeNode defaultNode = null;
    if (defaultValue != null) {
        defaultNode = new VirtualTreeNode(defaultValue, defaultHits);
    }
    try {
        DataTreeNode tmp;
        if (path != null) {
            DataTreeNode refnode = followPath(parent.getTreeRoot(), path);
            return refnode != null ? new ReferencePathIterator(refnode, parent) : null;
        }
        if (trap != null) {
            for (String name : trap) {
                for (ClosableIterator<DataTreeNode> iter = parent.getIterator(); iter.hasNext();) {
                    tmp = iter.next();
                    if (regex()) {
                        if (tmp.getName().matches(name)) {
                            iter.close();
                            return null;
                        }
                    } else {
                        if (tmp.getName().equals(name)) {
                            iter.close();
                            return null;
                        }
                    }
                }
            }
        }
        if ((match == null) && (regex == null) && (data == null)) {
            Iterator<DataTreeNode> result = parent.getIterator();
            if (result.hasNext() || (defaultNode == null)) {
                return result;
            } else {
                return Iterators.singletonIterator(defaultNode);
            }
        }
        ret = new LinkedList<>();
        if (match != null) {
            if (regex()) {
                if (regexPatterns == null) {
                    regexPatterns = new Pattern[match.length];
                    for (int i = 0; i < match.length; i++) {
                        regexPatterns[i] = Pattern.compile(match[i]);
                    }
                }
                for (Iterator<DataTreeNode> iter = parent.getIterator(); iter.hasNext();) {
                    tmp = iter.next();
                    for (Pattern name : regexPatterns) {
                        if (name.matcher(tmp.getName()).matches() ^ not()) {
                            ret.add(tmp);
                        }
                    }
                }
            } else if (range()) {
                if (match.length == 0) {
                    return parent.getIterator();
                } else if (match.length == 1) {
                    return parent.getIterator(match[0]);
                } else {
                    ArrayList<Iterator<DataTreeNode>> metaIterator = new ArrayList<>();
                    for (String name : match) {
                        metaIterator.add(parent.getIterator(name));
                    }
                    return Iterators.concat(metaIterator.iterator());
                }
            } else if (rangeStrict()) {
                return parent.getIterator(match.length > 0 ? match[0] : null,
                        match.length > 1 ? match[1] : null);
            } else if (data == null) {
                return new LazyNodeMatch(parent, match, defaultNode);
            } else {
                for (String name : match) {
                    DataTreeNode find = parent.getNode(name);
                    if (find != null) {
                        ret.add(find);
                    }
                }
            }
        }
        if (data != null) {
            if (regex()) {
                if (parent.getDataMap() != null) {
                    for (Map.Entry<String, TreeNodeData> actor : parent.getDataMap().entrySet()) {
                        int memSize = CodecBin2.encodeBytes(actor.getValue()).length;
                        ReadTreeNode memNode = new ReadTreeNode(actor.getKey(), memSize);
                        ret.add(memNode);
                    }
                }
            } else {
                DataTreeNodeActor actor = parent.getData(data);
                if (actor != null) {
                    Collection<DataTreeNode> nodes = actor.onNodeQuery(dataKey);
                    if (nodes != null) {
                        ret.addAll(nodes);
                    }
                }
            }
        }
    } catch (RuntimeException ex) {
        throw ex;
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    if ((ret.size() == 0) && (defaultNode != null)) {
        return Iterators.singletonIterator(defaultNode);
    } else {
        return ret.iterator();
    }
}

From source file:report.mainReport.java

public static String createsecuInfos(String dvId, int irang, LinkedList pList) {
    String secuInfos = "";
    int nbinfo = 0;
    int nbrdepvitesse = 0;

    for (int i = 0; i < pList.size(); i++) {
        Events evt = (Events) pList.get(i);
        if (evt.getDeviceID().equalsIgnoreCase(dvId)) {
            /*if (evt.getSpeed() < 1 ){ // Vrification nombre d'arrt
               int tmps = getDuration(pList, dvId, i);
              if (tmps > ARRET_MAX){//from   www  . j av a  2 s .c o m
              nbrarret ++;
              nbinfo ++;
              }
            }  */
            if (evt.getSpeed() > evt.getSpeedMax()) { // Vrification vitesse maximum
                nbrdepvitesse++;
                nbinfo++;
            }
        }
    }
    if (nbinfo > 0) {
        //nbrarret = nbrarret - 2; //On enlve le point de dpart et d'arriv
        if (nbrarret < 1)
            nbrarret = 0;
        secuInfos = secuInfos + "<div id=\"secu" + irang + "\" class=\"secuInfos\"><img id=\"imgEvent" + irang
                + "\" class=\"siCatIcon\"/><label class=\"siLabel\">Ev&egrave;nements";
        secuInfos = secuInfos
                + "</label><hr /><br /><table><tr><td><table class=\"alignToChart tableSecuInfos\"><tr><td class=\"tsiLabel\">Nombre total d'arr&ecirc; ts</td>";
        secuInfos = secuInfos + "<td class=\"tsiData\">" + nbrarret + "</td></tr>"
                + "<tr><td class=\"tsiLabel\">Nombre d'arr&ecirc; ts non-autoris&eacute;s</td><td class=\"tsiData\">0</td></tr></table>"
                + "</td><td><img id=\"secTabImgLegendStopOK" + irang
                + "\" class=\"secTabLegendImgAlt\"></td></tr></table><br /><table><tr><td>";
        secuInfos = secuInfos + "<table class=\"alignToChart tableSecuInfos\"><tr>"
                + "<td class=\"tsiLabel\">Nombre total de d&eacute;passements de vitesse</td><td class=\"tsiData\">"
                + nbrdepvitesse + "</td></tr>"
                + "<tr><td class=\"tsiLabel\">Dur&eacute;e totale en d&eacute;passement de vitesse</td><td class=\"tsiData\">00:00:00</td></tr><tr><td class=\"tsiLabel\">D&eacute;passements de vitesse / dur&eacute;e de roulage</td><td class=\"tsiData\">0.0%</td></tr></table></td><td>";
        secuInfos = secuInfos + "<img id=\"secTabImgLegendSpeed" + irang
                + "\" class=\"secTabLegendImg\"></td></tr></table><br /><table><tr><td>"
                + "<table class=\"alignToChart tableSecuInfos\"><tr><td class=\"tsiLabel\">Nombre d'acc&eacute;l&eacute;rations hors-norme</td>"
                + "<td class=\"tsiData\">0</td></tr><tr><td class=\"tsiLabel\">Dur&eacute;e en acc&eacute;l&eacute;ration hors-norme</td><td class=\"tsiData\">00:00:00</td></tr>"
                + "<tr><td class=\"tsiLabel\">Acc&eacute;l&eacute;rations hors-norme / dur&eacute;e de roulage</td><td class=\"tsiData\">0.0%</td></tr></table></td><td><img id=\"secTabImgAccAlarm"
                + irang + "\" class=\"secTabLegendImg\"></td></tr></table><br />";
        secuInfos = secuInfos
                + "<table><tr><td><table class=\"alignToChart tableSecuInfos\"><tr><td class=\"tsiLabel\">Nombre de d&eacute;c&eacute;l&eacute;rations hors-norme</td><td class=\"tsiData\">0</td>"
                + "</tr><tr><td class=\"tsiLabel\">Dur&eacute;e en d&eacute;c&eacute;l&eacute;ration hors-norme</td><td class=\"tsiData\">00:00:00</td></tr><tr><td class=\"tsiLabel\">D&eacute;c&eacute;l&eacute;rations hors-norme / dur&eacute;e de roulage"
                + "</td><td class=\"tsiData\">0.0%</td></tr></table></td><td><img id=\"secTabImgDecAlarm"
                + irang + "\" class=\"secTabLegendImg\"></td></tr></table><br /><br />";
        secuInfos = secuInfos + "<img id=\"imgChart" + irang
                + "\" class=\"siCatIcon\"/><label class=\"siLabel\">Vitesse</label><hr /><br />"
                + "<div class=\"alignToChart\">S&eacute;lectionnez une zone du graphe avec la souris pour zoomer. Double-cliquez pour revenir au niveau de zoom initial."
                + "<br/>Passez la souris sur la graphe pour afficher le d&eacute;tail d'un point.</div><br/><div><div id=\"speedChart"
                + irang + "\" class=\"speedChart\"></div></div><br/><br/></div>";
    }
    return secuInfos;
}

From source file:util.method.java

public static HOST findHOSTByIDFromHOSTList(LinkedList<HOST> HOSTList, String HOSTID) {

    for (int i = 0; i < HOSTList.size(); i++) {
        HOST currentHOST = HOSTList.get(i);
        if (currentHOST.getID().equals(HOSTID))
            return currentHOST;
    }/*from  w  w w.  j a v  a2 s. c  om*/

    return null;

}