Example usage for java.util LinkedList removeFirst

List of usage examples for java.util LinkedList removeFirst

Introduction

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

Prototype

public E removeFirst() 

Source Link

Document

Removes and returns the first element from this list.

Usage

From source file:elh.eus.absa.Features.java

/**
 *     Lemma ngram extraction from a kaf document
 * //from w w  w  .j a v a  2  s .  c  o m
 * @param int length : which 'n' use for 'n-grams' 
 * @param KAFDocument kafDoc : postagged kaf document to extract ngrams from.
 * @param boolean save : safe ngrams to file or not. 
 * @return TreeSet<String> return lemma ngrams of length length
 */
private int extractLemmaNgrams(int length, KAFDocument kafDoc, List<String> discardPos, boolean save) {
    //System.err.println("lemma ngram extraction: _"+length+"_");
    if (length == 0) {
        return 0;
    }

    int sentNum = kafDoc.getSentences().size();
    for (int s = 0; s < sentNum; s++) {
        LinkedList<String> ngrams = new LinkedList<String>();
        for (Term term : kafDoc.getTermsBySent(s)) {
            if (ngrams.size() >= length) {
                ngrams.removeFirst();
            }

            //if no alphanumeric char is present discard the element as invalid ngram. Or if it has a PoS tag that
            //should be discarded              
            String lCurrent = term.getLemma();
            if ((!discardPos.contains(term.getPos()))
                    && (!lCurrent.matches("[^\\p{L}\\p{M}\\p{Nd}\\p{InEmoticons}]+"))
                    && (lCurrent.length() > 1)) {
                ngrams.add(lCurrent);
                //ngrams.add(normalize(term.getLemma(), params.getProperty("normalization", "none")));
            }
            //certain punctuation marks and emoticons are allowed as lemmas
            else if ((lCurrent.length() <= 2) && (lCurrent.matches("[,;.?!]"))) {
                ngrams.add(lCurrent);
            }

            // add ngrams to the feature list
            for (int i = 0; i < ngrams.size(); i++) {
                String ng = featureFromArray(ngrams.subList(0, i + 1), "lemma");
                addNgram("lemma", ng);
            }
        }
        //empty ngram list and add remaining ngrams to the feature list
        while (!ngrams.isEmpty()) {
            String ng = featureFromArray(ngrams, "lemma");
            addNgram("lemma", ng);
            ngrams.removeFirst();
        }
    }
    return 1;
}

From source file:org.apache.activemq.leveldb.test.ReplicatedLevelDBStoreTest.java

@Test(timeout = 1000 * 60 * 10)
public void testReplication() throws Exception {

    LinkedList<File> directories = new LinkedList<File>();
    directories.add(new File("target/activemq-data/leveldb-node1"));
    directories.add(new File("target/activemq-data/leveldb-node2"));
    directories.add(new File("target/activemq-data/leveldb-node3"));
    resetDirectories(directories);/*from   ww  w . j a va 2s  .  c o m*/

    // For some reason this had to be 64k to trigger a bug where
    // slave index snapshots were being done incorrectly.
    String playload = createPlayload(64 * 1024);

    ArrayList<String> expected_list = new ArrayList<String>();
    // We will rotate between 3 nodes the task of being the master.
    for (int j = 0; j < 5; j++) {

        MasterLevelDBStore master = createMaster(directories.get(0));
        CountDownFuture masterStart = asyncStart(master);
        SlaveLevelDBStore slave1 = createSlave(master, directories.get(1));
        SlaveLevelDBStore slave2 = createSlave(master, directories.get(2));
        asyncStart(slave2);
        masterStart.await();

        if (j == 0) {
            stores.add(master);
            stores.add(slave1);
            stores.add(slave2);
        }

        MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST"));

        LOG.info("Checking: " + master.getDirectory());
        assertEquals(expected_list, getMessages(ms));

        LOG.info("Adding messages...");
        final int TOTAL = 500;
        for (int i = 0; i < TOTAL; i++) {
            if (i % ((int) (TOTAL * 0.10)) == 0) {
                LOG.info("" + (100 * i / TOTAL) + "% done");
            }

            if (i == 250) {
                slave1.start();
                slave2.stop();
                LOG.info("Checking: " + master.getDirectory());
                assertEquals(expected_list, getMessages(ms));
            }

            String msgid = "m:" + j + ":" + i;
            addMessage(ms, msgid, playload);
            expected_list.add(msgid);
        }

        LOG.info("Checking: " + master.getDirectory());
        assertEquals(expected_list, getMessages(ms));

        LOG.info("Stopping master: " + master.getDirectory());
        master.stop();

        Thread.sleep(3 * 1000);
        LOG.info("Stopping slave: " + slave1.getDirectory());
        slave1.stop();

        // Rotate the dir order so that slave1 becomes the master next.
        directories.addLast(directories.removeFirst());
    }
}

From source file:org.dbpedia.spotlight.mediawiki.ModularParser.java

private SectionContainer parseSections(SpanManager sm, ContentElementParsingParameters cepp,
        LinkedList<Span> lineSpans) {

    List<SectionContent> contentSections = new ArrayList<SectionContent>();

    SectionContent sc = new SectionContent(1);

    if (calculateSrcSpans) {
        try {//  ww w.jav a 2 s .c o m
            sc.setSrcSpan(new SrcSpan(sm.getSrcPos(lineSpans.getFirst().getStart()), -1));
        } catch (Exception e) {
            System.out.println("Parse error :" + sm.toString());
        }
    }

    // Identify the Line Type and call the necessary Function for the
    // further handling...
    while (!lineSpans.isEmpty()) {

        Span s = lineSpans.getFirst();

        lineType t = getLineType(sm, s);
        switch (t) {
        case SECTION:
            contentSections.add(sc);
            int level = getSectionLevel(sm, s);
            sc = new SectionContent(
                    parseContentElement(sm, cepp, new Span(s.getStart() + level, s.getEnd() - level).trim(sm)),
                    level);
            lineSpans.removeFirst();

            if (calculateSrcSpans) {
                sc.setSrcSpan(new SrcSpan(sm.getSrcPos(s.getStart()), -1));
            }

            break;

        case HR:
            // remove the HR (----) and handle the rest as a parapraph line
            removeHr(sm, s);
            t = lineType.PARAGRAPH;
        case PARAGRAPH:
        case PARAGRAPH_BOXED:
        case PARAGRAPH_INDENTED:
            sc.addParagraph(buildParagraph(sm, cepp, lineSpans, t));
            break;

        case NESTEDLIST:
        case NESTEDLIST_NR:
            sc.addNestedList(buildNestedList(sm, cepp, lineSpans, t));
            break;

        case DEFINITIONLIST:
            sc.addDefinitionList(buildDefinitionList(sm, cepp, lineSpans));
            break;

        case TABLE:
            sc.addTable(buildTable(sm, cepp, lineSpans));
            break;

        case EMPTYLINE:
            lineSpans.removeFirst();
            break;

        default:
            logger.error("unknown lineStart!: \"" + sm.substring(s) + "\"");
            lineSpans.removeFirst();
        }
    }

    // add the remaining Section to the list.
    contentSections.add(sc);

    return buildSectionStructure(contentSections);
}

From source file:tokyo.northside.jrst.JRSTReader.java

/**
 * @param title//  w w  w  . ja va  2s  .co m
 *            <Element> title, String num
 * @return Element
 */
private Element composeLineContent(LinkedList<Element> title, String num) {
    Element result = DocumentHelper.createElement(BULLET_LIST);
    if (sectnum) {
        result.addAttribute(CLASS, "auto-toc");
    }
    Element item = null;
    int cnt = 0;
    while (!title.isEmpty()) {

        Element e = title.getFirst();
        int level = Integer.parseInt(e.attributeValue(LEVEL));
        LinkedList<Element> child = new LinkedList<Element>();

        if (level <= 0) {
            cnt++;
            title.removeFirst();
            item = result.addElement(LIST_ITEM);
            Element para = item.addElement(PARAGRAPH);
            Element reference = para.addElement(REFERENCE);
            String text = e.getText();
            String id = e.attributeValue(ATTR_REFID);
            reference.addAttribute(ATTR_IDS, id);
            reference.addAttribute(ATTR_REFID,
                    text.replaceAll("\\W+", " ").trim().toLowerCase().replaceAll("\\W+", "-"));
            // si l'on doit les numeroter
            if (sectnum) {
                Element generated = reference.addElement(GENERATED).addAttribute(CLASS, SECTNUM);
                generated.setText(num + cnt + "   ");
                for (int i = 0; i < eTitle.size(); i++) {
                    if (eTitle.get(i).attributeValue(ATTR_REFID).equals(id)) {
                        Element generatedTitle = eTitle.get(i).addElement(GENERATED);
                        generatedTitle.addAttribute(CLASS, SECTNUM);
                        generatedTitle.setText(num + cnt + "   ");
                    }

                }
            }

            text = text.trim();
            text = text.replaceAll("_", "");

            text = REGEX_STRONG.matcher(text).replaceAll("<" + STRONG + ">$1</" + STRONG + ">");
            text = REGEX_EMPHASIS.matcher(text).replaceAll("<" + EMPHASIS + ">$1</" + EMPHASIS + ">");

            try {
                Element textElement = DocumentHelper.parseText("<TMP>" + text + "</TMP>").getRootElement();
                reference.appendContent(textElement);

            } catch (DocumentException eee) {
                if (log.isWarnEnabled()) {
                    log.warn("Can't inline text for " + e, eee);
                }
            }

        } else {
            do {
                e.addAttribute(LEVEL, "" + (level - 1));
                child.add(e);
                title.removeFirst();
                if (!title.isEmpty()) {
                    e = title.getFirst();
                    level = Integer.parseInt(e.attributeValue(LEVEL));
                }
            } while (!title.isEmpty() && level > 0);
            String numTmp = "";
            // numerotation
            if (sectnum) {
                numTmp = num + cnt + ".";
            }
            if (item != null) {
                item.add(composeLineContent(child, numTmp)); // Appel
                // recursif
            } else {
                result.add(composeLineContent(child, numTmp)); // Appel
                // recursif
            }
        }
    }
    return result;
}

From source file:org.deeplearning4j.nn.graph.ComputationGraph.java

/**
 * Calculate a topological sort order for the vertices in the graph.
 * Note that this is used for/*from w  w  w .j  a  v a  2s  .  c  om*/
 * (a) working out what order to do forward pass,
 * (b) what order to do backprop (i.e., reverse of this)
 * (c) order to flatten parameters (and gradients)
 */
public int[] topologicalSortOrder() {
    if (topologicalOrder != null)
        return topologicalOrder;

    //https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
    Map<String, org.deeplearning4j.nn.conf.graph.GraphVertex> nodeMap = configuration.getVertices();
    List<String> networkInputNames = configuration.getNetworkInputs();
    int numVertices = networkInputNames.size() + configuration.getVertices().size();
    int[] out = new int[numVertices];
    int outCounter = 0;

    //First: represent the graph more usefully as a Map<Integer,Set<Integer>>, where map represents edges i -> j
    // key represents j, set is set of i (inputs) for vertices j
    Map<Integer, String> vertexNamesMap = new HashMap<>();
    Map<String, Integer> vertexNamesMap2 = new HashMap<>();
    int i = 0;
    for (String inputName : configuration.getNetworkInputs()) {
        vertexNamesMap.put(i, inputName);
        vertexNamesMap2.put(inputName, i);
        i++;
    }
    for (Map.Entry<String, org.deeplearning4j.nn.conf.graph.GraphVertex> entry : nodeMap.entrySet()) {
        String name = entry.getKey();
        vertexNamesMap.put(i, name);
        vertexNamesMap2.put(name, i);
        i++;
    }

    Map<Integer, Set<Integer>> inputEdges = new HashMap<>(); //key: vertex. Values: vertices that the key vertex receives input from
    Map<Integer, Set<Integer>> outputEdges = new HashMap<>(); //key: vertex. Values: vertices that the key vertex outputs to

    for (String s : configuration.getNetworkInputs()) {
        int idx = vertexNamesMap2.get(s);
        inputEdges.put(idx, null);
    }

    for (Map.Entry<String, org.deeplearning4j.nn.conf.graph.GraphVertex> entry : nodeMap.entrySet()) {
        String thisVertexName = entry.getKey();
        int idx = vertexNamesMap2.get(thisVertexName);
        List<String> inputsToThisVertex = configuration.getVertexInputs().get(thisVertexName);

        if (inputsToThisVertex == null || inputsToThisVertex.isEmpty()) {
            inputEdges.put(idx, null);
            continue;
        }

        Set<Integer> inputSet = new HashSet<>();
        for (String s : inputsToThisVertex) {
            Integer inputIdx = vertexNamesMap2.get(s);
            if (inputIdx == null) {
                System.out.println();
            }
            inputSet.add(inputIdx);
            Set<Integer> outputSetForInputIdx = outputEdges.get(inputIdx);
            if (outputSetForInputIdx == null) {
                outputSetForInputIdx = new HashSet<>();
                outputEdges.put(inputIdx, outputSetForInputIdx);
            }
            outputSetForInputIdx.add(idx); //input vertex outputs to the current vertex
        }
        inputEdges.put(idx, inputSet);
    }

    //Now: do topological sort
    //Set of all nodes with no incoming edges: (this would be: input vertices)
    LinkedList<Integer> noIncomingEdges = new LinkedList<>();
    for (Map.Entry<Integer, Set<Integer>> entry : inputEdges.entrySet()) {
        Set<Integer> inputsFrom = entry.getValue();
        if (inputsFrom == null || inputsFrom.isEmpty()) {
            noIncomingEdges.add(entry.getKey());
        }
    }

    while (!noIncomingEdges.isEmpty()) {
        int next = noIncomingEdges.removeFirst();
        out[outCounter++] = next; //Add to sorted list

        Set<Integer> vertexOutputsTo = outputEdges.get(next);

        //Remove edges next -> vertexOuputsTo[...] from graph;
        if (vertexOutputsTo != null) {
            for (Integer v : vertexOutputsTo) {
                Set<Integer> set = inputEdges.get(v);
                set.remove(next);
                if (set.isEmpty()) {
                    noIncomingEdges.add(v); //No remaining edges for vertex i -> add to list for processing
                }
            }
        }
    }

    //If any edges remain in the graph: graph has cycles:
    for (Map.Entry<Integer, Set<Integer>> entry : inputEdges.entrySet()) {
        Set<Integer> set = entry.getValue();
        if (set == null)
            continue;
        if (!set.isEmpty())
            throw new IllegalStateException(
                    "Invalid configuration: cycle detected in graph. Cannot calculate topological ordering with graph cycle ("
                            + "cycle includes vertex \"" + vertexNamesMap.get(entry.getKey()) + "\")");
    }

    return out;
}

From source file:com.redsqirl.workflow.server.Workflow.java

/**
 * Do sort of the workflow./* w w w  .j  a  v  a  2  s. co m*/
 * 
 * If the sort is successful, it is a DAG
 * 
 * @return null if OK, or a description of the error.
 * @throws RemoteException
 */
public String topoligicalSort() throws RemoteException {
    String error = null;
    LinkedList<DataFlowElement> newList = new LinkedList<DataFlowElement>();

    LinkedList<DataFlowElement> queueList = new LinkedList<DataFlowElement>();
    Iterator<DataFlowElement> iconIt = element.iterator();
    while (iconIt.hasNext()) {
        DataFlowElement cur = iconIt.next();
        if (cur.getInputComponent().values().size() == 0) {
            queueList.add(cur);
        }
    }

    while (!queueList.isEmpty()) {
        newList.add(queueList.removeFirst());
        iconIt = element.iterator();
        while (iconIt.hasNext()) {
            DataFlowElement cur = iconIt.next();
            if (!newList.contains(cur) && !queueList.contains(cur)) {
                Iterator<List<DataFlowElement>> it = cur.getInputComponent().values().iterator();
                boolean allThere = true;
                while (it.hasNext() && allThere) {
                    allThere = newList.containsAll(it.next());
                }

                if (allThere) {
                    queueList.add(cur);
                }
            }
        }
    }
    if (newList.size() < element.size()) {
        error = LanguageManagerWF.getText("workflow.topologicalSort");
    } else {
        element = newList;
    }

    return error;
}

From source file:elh.eus.absa.Features.java

/**
 * Given a window check if the ngrams inside (all of them) are present in the feature set, and if so, 
 * update the feature vector accordingly
 * /*from ww  w. ja v a2 s . com*/
 * @param ngrams
 * @param prefix String : possible prefix used to differentiate ngram groups in the attribute set.
 * @param double[] fVector : feature vector for the corresponding instance
 * @param int tokens : number of tokens in the sentence (in case we want to add not a frequency value
 * but a normalized value)
 * 
 */
private void checkNgramFeatures(LinkedList<String> ngrams, double[] fVector, String prefix, int tokens,
        boolean empty) {
    //System.err.println("features::checkNgramFeatures ->"+Arrays.asList(ngrams).toString());

    // if empty is active means that we are checking the end of the sentence and 
    // the ngram list must be emptied 
    if (empty) {
        while (!ngrams.isEmpty()) {
            String ng = featureFromArray(ngrams, prefix);
            //add occurrence to feature vector (the functions checks if the given ngram feature exists).
            addNumericToFeatureVector(ng, fVector, tokens); //tokNum

            ngrams.removeFirst();
        }
    }
    // if empty is false search for all ngrams in the window
    else {
        // add ngrams to the feature list
        for (int i = 0; i < ngrams.size(); i++) {
            String ng = featureFromArray(ngrams.subList(0, i + 1), prefix);
            // add occurrence to feature vector (the functions checks if the given ngram feature exists). 
            addNumericToFeatureVector(ng, fVector, tokens);//tokNum
        }
    }
}

From source file:com.zimbra.cs.service.mail.ToXML.java

private static void addParts(Element root, MPartInfo mpiRoot, Set<MPartInfo> bodies, String prefix, int maxSize,
        boolean neuter, boolean excludeCalendarParts, String defaultCharset, boolean swallowContentExceptions,
        MsgContent wantContent) throws ServiceException {
    MPartInfo mpi = mpiRoot;/*from   w  w  w . j  a  v a2s  .com*/
    LinkedList<Pair<Element, LinkedList<MPartInfo>>> queue = new LinkedList<Pair<Element, LinkedList<MPartInfo>>>();
    Pair<Element, LinkedList<MPartInfo>> level = new Pair<Element, LinkedList<MPartInfo>>(root,
            new LinkedList<MPartInfo>());
    level.getSecond().add(mpi);
    queue.add(level);

    VisitPhase phase = VisitPhase.PREVISIT;
    while (!queue.isEmpty()) {
        level = queue.getLast();
        LinkedList<MPartInfo> parts = level.getSecond();
        if (parts.isEmpty()) {
            queue.removeLast();
            phase = VisitPhase.POSTVISIT;
            continue;
        }

        mpi = parts.getFirst();
        Element child = addPart(phase, level.getFirst(), root, mpi, bodies, prefix, maxSize, neuter,
                excludeCalendarParts, defaultCharset, swallowContentExceptions, wantContent);
        if (phase == VisitPhase.PREVISIT && child != null && mpi.hasChildren()) {
            queue.addLast(new Pair<Element, LinkedList<MPartInfo>>(child,
                    new LinkedList<MPartInfo>(mpi.getChildren())));
        } else {
            parts.removeFirst();
            phase = VisitPhase.PREVISIT;
        }
    }
}

From source file:de.tudarmstadt.ukp.wikipedia.parser.mediawiki.ModularParser.java

/**
 * Building a ContentElement, this funciton is calles by all the other
 * parseContentElement(..) functions//from  w  ww.jav a 2  s  .co  m
 */
private ContentElement parseContentElement(SpanManager sm, ContentElementParsingParameters cepp,
        LinkedList<Span> lineSpans, ContentElement result) {

    List<Link> localLinks = new ArrayList<Link>();
    List<Template> localTemplates = new ArrayList<Template>();

    List<Span> boldSpans = new ArrayList<Span>();
    List<Span> italicSpans = new ArrayList<Span>();
    sm.manageList(boldSpans);
    sm.manageList(italicSpans);

    List<Span> managedSpans = new ArrayList<Span>();
    sm.manageList(managedSpans);

    Span contentElementRange = new Span(lineSpans.getFirst().getStart(), lineSpans.getLast().getEnd()).trim(sm);
    managedSpans.add(contentElementRange);

    // set the SrcSpan
    if (calculateSrcSpans) {
        result.setSrcSpan(new SrcSpan(sm.getSrcPos(contentElementRange.getStart()),
                sm.getSrcPos(contentElementRange.getEnd())));
    }

    sm.manageList(lineSpans);
    while (!lineSpans.isEmpty()) {
        Span line = lineSpans.getFirst();

        parseBoldAndItalicSpans(sm, line, boldSpans, italicSpans);

        // External links
        parseExternalLinks(sm, line, "http://", managedSpans, localLinks, result);
        parseExternalLinks(sm, line, "https://", managedSpans, localLinks, result);
        parseExternalLinks(sm, line, "ftp://", managedSpans, localLinks, result);
        parseExternalLinks(sm, line, "mailto:", managedSpans, localLinks, result);

        // end of linewhise opperations
        lineSpans.removeFirst();
    }
    sm.removeManagedList(lineSpans);

    // Links
    int i;
    i = 0;
    while (i < cepp.linkSpans.size()) {
        if (contentElementRange.hits(cepp.linkSpans.get(i))) {
            Span linkSpan = cepp.linkSpans.remove(i);
            managedSpans.add(linkSpan);
            Link l = cepp.links.remove(i).setHomeElement(result);
            localLinks.add(l);
            if (!showImageText && l.getType() == Link.type.IMAGE) {
                // deletes the Image Text from the ContentElement Text.
                sm.delete(linkSpan);
            }
        } else {
            i++;
        }
    }

    // Templates
    i = 0;
    while (i < cepp.templateSpans.size()) {
        Span ts = cepp.templateSpans.get(i);
        if (contentElementRange.hits(ts)) {
            ResolvedTemplate rt = cepp.templates.remove(i);

            if (rt.getPostParseReplacement() != null) {
                sm.replace(ts, rt.getPostParseReplacement());
            }
            cepp.templateSpans.remove(i);

            Object parsedObject = rt.getParsedObject();
            if (parsedObject != null) {
                managedSpans.add(ts);

                Class parsedObjectClass = parsedObject.getClass();
                if (parsedObjectClass == Template.class) {
                    localTemplates.add((Template) parsedObject);
                } else if (parsedObjectClass == Link.class) {
                    localLinks.add(((Link) parsedObject).setHomeElement(result));
                } else {
                    localTemplates.add(rt.getTemplate());
                }
            }
        } else {
            i++;
        }
    }

    // HTML/XML Tags
    i = 0;
    List<Span> tags = new ArrayList<Span>();
    while (i < cepp.tagSpans.size()) {
        Span s = cepp.tagSpans.get(i);
        if (contentElementRange.hits(s)) {
            cepp.tagSpans.remove(i);
            if (deleteTags) {
                sm.delete(s);
            } else {
                tags.add(s);
                managedSpans.add(s);
            }
        } else {
            i++;
        }
    }

    // noWiki
    i = 0;
    List<Span> localNoWikiSpans = new ArrayList<Span>();
    while (i < cepp.noWikiSpans.size()) {
        Span s = cepp.noWikiSpans.get(i);
        if (contentElementRange.hits(s)) {
            cepp.noWikiSpans.remove(i);
            sm.replace(s, cepp.noWikiStrings.remove(i));
            localNoWikiSpans.add(s);
            managedSpans.add(s);
        } else {
            i++;
        }
    }

    // MATH Tags
    i = 0;
    List<Span> mathSpans = new ArrayList<Span>();
    while (i < cepp.mathSpans.size()) {
        Span s = cepp.mathSpans.get(i);
        if (contentElementRange.hits(s)) {
            cepp.mathSpans.remove(i);

            if (showMathTagContent) {
                mathSpans.add(s);
                managedSpans.add(s);
                sm.replace(s, cepp.mathStrings.remove(i));
            } else {
                sm.delete(s);
            }
        } else {
            i++;
        }
    }

    result.setText(sm.substring(contentElementRange));

    // managed spans must be removed here and not earlier, because every
    // change in the SpanManager affects the Spans!
    sm.removeManagedList(boldSpans);
    sm.removeManagedList(italicSpans);
    sm.removeManagedList(managedSpans);

    // contentElementRange ist auch noch in managedSpans !!! deswegen:
    final int adjust = -contentElementRange.getStart();
    for (Span s : boldSpans) {
        s.adjust(adjust);
    }
    for (Span s : italicSpans) {
        s.adjust(adjust);
    }
    for (Span s : managedSpans) {
        s.adjust(adjust);
    }

    result.setFormatSpans(FormatType.BOLD, boldSpans);
    result.setFormatSpans(FormatType.ITALIC, italicSpans);
    result.setFormatSpans(FormatType.TAG, tags);
    result.setFormatSpans(FormatType.MATH, mathSpans);
    result.setFormatSpans(FormatType.NOWIKI, localNoWikiSpans);

    result.setLinks(sortLinks(localLinks));
    result.setTemplates(sortTemplates(localTemplates));

    return result;
}

From source file:com.google.dart.engine.services.completion.CompletionEngine.java

private void currentLibraryLister(LinkedList<LibraryElement> queue, Set<LibraryElement> libraries) {
    while (!queue.isEmpty()) {
        LibraryElement sourceLib = queue.removeFirst();
        libraries.add(sourceLib);/*from   w w w.ja  v  a 2  s.c  o  m*/
        LibraryElement[] expLibs = sourceLib.getExportedLibraries();
        for (LibraryElement lib : expLibs) {
            if (!libraries.contains(lib)) {
                queue.add(lib);
            }
        }
    }
}