Example usage for com.google.common.collect Lists newLinkedList

List of usage examples for com.google.common.collect Lists newLinkedList

Introduction

In this page you can find the example usage for com.google.common.collect Lists newLinkedList.

Prototype

@GwtCompatible(serializable = true)
public static <E> LinkedList<E> newLinkedList() 

Source Link

Document

Creates a mutable, empty LinkedList instance (for Java 6 and earlier).

Usage

From source file:com.isotrol.impe3.palette.menu.MenuItem.java

public List<MenuItem> getChildren() {
    if (children == null) {
        children = Lists.newLinkedList();
    }
    return children;
}

From source file:com.textocat.textokit.commons.cas.ImmutableAugmentedIntervalTree.java

public List<OffsetsWithValue<V>> getOverlapping(int begin, int end) {
    if (root == null) {
        return Collections.emptyList();
    }/*  ww w.  j  a  va  2s.co m*/
    List<OffsetsWithValue<V>> resultList = Lists.newLinkedList();
    search(root, new Offsets(begin, end), resultList);
    return resultList;
}

From source file:com.griddynamics.jagger.master.configuration.WorkloadTasksGenerator.java

public List<Task> generate() {
    validate();//from  ww w .j  a va2 s .  c o m

    List<Task> result = Lists.newLinkedList();
    int number = 0;
    for (WorkloadClockConfiguration clock : clocks) {
        for (WorkloadTask prototype : prototypes) {
            for (TerminateStrategyConfiguration termination : terminations) {
                WorkloadTask workloadTask = prototype.copy();
                workloadTask.setNumber(++number);
                workloadTask.setName(workloadTask.getName() + "---" + stringOf(termination));
                workloadTask.setTerminateStrategyConfiguration(termination);
                workloadTask.setClockConfiguration(clock);

                Task task = workloadTask;
                if (attendantMonitoring != null) {
                    CompositeTask composite = new CompositeTask();
                    composite.setLeading(ImmutableList.<CompositableTask>of(workloadTask));
                    composite.setAttendant(ImmutableList.<CompositableTask>of(attendantMonitoring));

                    task = composite;
                }

                result.add(task);
            }
        }
    }
    return result;
}

From source file:org.apache.tez.analyzer.plugins.ContainerReuseAnalyzer.java

@Override
public void analyze(DagInfo dagInfo) throws TezException {
    for (VertexInfo vertexInfo : dagInfo.getVertices()) {
        Multimap<Container, TaskAttemptInfo> containers = vertexInfo.getContainersMapping();
        for (Container container : containers.keySet()) {
            List<String> record = Lists.newLinkedList();
            record.add(vertexInfo.getVertexName());
            record.add(vertexInfo.getTaskAttempts().size() + "");
            record.add(container.getHost());
            record.add(container.getId());
            record.add(Integer.toString(containers.get(container).size()));
            csvResult.addRecord(record.toArray(new String[record.size()]));
        }//from w  w w .  j ava  2 s .c o m
    }
}

From source file:com.zimbra.doc.soap.Service.java

public List<Command> getCommands() {
    List<Command> allCommands = Lists.newLinkedList();

    Iterator<Command> cit = this.commands.iterator();
    while (cit.hasNext()) {
        Command c = cit.next();//from w w w. java 2 s. co  m
        allCommands.add(c);
    }

    Collections.sort(allCommands, new Command.CommandComparator());

    return allCommands;
}

From source file:org.nmdp.ngs.align.Blastn.java

/**
 * Return the high-scoring segment pairs (HSPs) from blastn of the source and target sequence files in FASTA format.
 *
 * @param sourceFile source sequence file in FASTA format, must not be null
 * @param targetFile target sequence file in FASTA format, must not be null
 * @return zero or more high-scoring segment pairs (HSPs) from blastn of the source and target sequence files
 *    in FASTA format/* w w  w  .j  a va2s .  c o  m*/
 * @throws IOException if an I/O error occurs
 */
public static Iterable<HighScoringPair> blastn(final File sourceFile, final File targetFile)
        throws IOException {
    checkNotNull(sourceFile);
    checkNotNull(targetFile);

    File blastResult = File.createTempFile("blastn", ".txt");

    // blastn can't handle compressed files, so copy source and target to temp files, decompressing if necessary
    File sourceFileCopy = File.createTempFile("sourceFile", ".fa");
    charSource(sourceFile).copyTo(Files.asCharSink(sourceFileCopy, Charset.forName("UTF-8")));

    File targetFileCopy = File.createTempFile("targetFile", ".fa");
    charSource(targetFile).copyTo(Files.asCharSink(targetFileCopy, Charset.forName("UTF-8")));

    ProcessBuilder blastn = new ProcessBuilder("blastn", "-subject", sourceFileCopy.getPath(), "-query",
            targetFileCopy.getPath(), "-outfmt", "6", "-out", blastResult.getPath());
    Process blastnProcess = blastn.start();
    try {
        blastnProcess.waitFor();
    } catch (InterruptedException e) {
        // ignore
    }

    BufferedReader reader = null;
    List<HighScoringPair> hsps = Lists.newLinkedList();
    try {
        reader = new BufferedReader(new FileReader(blastResult));
        for (HighScoringPair hsp : HspReader.read(reader)) {
            hsps.add(hsp);
        }
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
            // empty
        }
        sourceFileCopy.delete();
        targetFileCopy.delete();
    }
    return ImmutableList.copyOf(hsps);
}

From source file:org.apache.streams.data.moreover.MoreoverProvider.java

public MoreoverProvider(MoreoverConfiguration moreoverConfiguration) {
    this.config = moreoverConfiguration;
    this.keys = Lists.newArrayList();
    for (MoreoverKeyData apiKey : config.getApiKeys()) {
        this.keys.add(apiKey);
    }//from ww  w.  j av a2s  . c  om
    this.providerTasks = Lists.newLinkedList();
}

From source file:ru.frostman.web.classloading.enhance.EnhancerUtil.java

public static List<CtMethod> getDeclaredMethodsAnnotatedWith(Class<? extends Annotation> annotation,
        CtClass ctClass) throws BytecodeManipulationException {
    try {//from  w w  w  .ja v a2 s . co m
        List<CtMethod> annotated = Lists.newLinkedList();

        for (CtMethod method : ctClass.getDeclaredMethods()) {
            if (method.getAnnotation(annotation) != null) {
                annotated.add(method);
            }
        }

        return annotated;
    } catch (Exception e) {
        throw new BytecodeManipulationException("Error in filtering methods of class", e);
    }
}

From source file:org.gradle.internal.util.Alignment.java

/**
 * Implements the Wagner-Fischer algorithm (https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm) to align 2 sequences of elements.
 * @param current a sequence of elements
 * @param previous the sequence to align to
 * @param <T> the type of the elements of the sequence
 * @return a list of alignments, telling if an element was added, removed, identical, or mutated
 */// w  ww. j  a  va  2 s .c  om
public static <T> List<Alignment<T>> align(T[] current, T[] previous) {
    int currentLen = current.length;
    int previousLen = previous.length;
    int[][] costs = new int[currentLen + 1][previousLen + 1];
    for (int j = 0; j <= previousLen; j++) {
        costs[0][j] = j;
    }
    for (int i = 1; i <= currentLen; i++) {
        costs[i][0] = i;
        for (int j = 1; j <= previousLen; j++) {
            costs[i][j] = Math.min(Math.min(costs[i - 1][j], costs[i][j - 1]) + 1,
                    current[i - 1].equals(previous[j - 1]) ? costs[i - 1][j - 1] : costs[i - 1][j - 1] + 1);
        }
    }

    List<Alignment<T>> result = Lists.newLinkedList();
    for (int i = currentLen, j = previousLen; i > 0 || j > 0;) {
        int cost = costs[i][j];
        if (i > 0 && j > 0 && cost == (current[i - 1].equals(previous[j - 1]) ? costs[i - 1][j - 1]
                : costs[i - 1][j - 1] + 1)) {
            T a = current[--i];
            T b = previous[--j];
            if (a.equals(b)) {
                result.add(0, new Alignment<T>(b, a));
            } else {
                result.add(0, new Alignment<T>(b, a));
            }
        } else if (i > 0 && cost == 1 + costs[i - 1][j]) {
            result.add(0, new Alignment<T>(null, current[--i]));
        } else if (j > 0 && cost == 1 + costs[i][j - 1]) {
            result.add(0, new Alignment<T>(previous[--j], null));
        } else {
            throw new IllegalStateException("Unexpected cost matrix");
        }
    }
    return result;
}

From source file:org.eclipse.emf.compare.tests.match.data.MatchInputData.java

public List<Resource> getRootIDTwoWayA1Right() throws IOException {
    List<Resource> result = Lists.newLinkedList();
    result.add(loadFromClassLoader("rootid/twoway/a1/right.nodes"));
    result.add(loadFromClassLoader("rootid/twoway/a1/right2.nodes"));
    return result;
}