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:org.sonatype.nexus.commands.CommandSupport.java

protected void addArgumentCompleter(final int index, final Completer completer) {
    if (argumentCompleters == null) {
        argumentCompleters = Lists.newLinkedList();
    }/*from w w  w.  jav  a2 s.  com*/
    argumentCompleters.add(index, completer);
}

From source file:com.github.fhirschmann.clozegen.lib.util.MultisetUtils.java

/**
 * Returns a limited list of all (distinct) elements of a multiset ordered
 * by their counts./*from  w  w  w.  jav a2 s. co  m*/
 *
 * @param <E> the type of the multiset elements
 * @param multiset the multiset to work on
 * @param limit the maximum number of elements to return
 * @return a limited list of elements ordered by their count
 */
public static <E> List<E> sortedElementList(final Multiset<E> multiset, final int limit) {
    final List<E> list = Lists.newLinkedList();
    final LinkedHashMultiset<E> sms = sortMultiSet(multiset);
    int newlimit = limit;

    if (newlimit > multiset.elementSet().size()) {
        throw new IllegalArgumentException("The multiset does not contain that many keys.");
    } else if (newlimit == -1) {
        newlimit = multiset.elementSet().size();
    }

    final Iterator<E> it = sms.iterator();

    E next;
    while (list.size() < newlimit) {
        next = it.next();
        if (!list.contains(next)) {
            list.add(next);
        }
    }
    return list;
}

From source file:com.google.cloud.genomics.dataflow.readers.bam.BAMShard.java

/**
 * Begins a new shard with an empty chunk list and a starting locus.
 *//*from  w  w  w.  j  a v a2  s . c o  m*/
public BAMShard(String file, String referenceName, long firstLocus) {
    this.file = file;
    this.contig = new Contig(referenceName, firstLocus, -1);
    this.chunks = Lists.newLinkedList();
    this.span = null;
}

From source file:org.apache.hadoop.hbase.monitoring.MemoryBoundedLogMessageBuffer.java

public MemoryBoundedLogMessageBuffer(long maxSizeBytes) {
    Preconditions.checkArgument(maxSizeBytes > 0);
    this.maxSizeBytes = maxSizeBytes;
    this.messages = Lists.newLinkedList();
}

From source file:com.twitter.elephanttwin.retrieval.CountTimestampSamplesWritable.java

@Override
public void readFields(DataInput dataInput) throws IOException {
    this.countTimestampWritable = new CountTimestampWritable(0, 0);
    this.countTimestampWritable.readFields(dataInput);
    int numSamples = dataInput.readInt();
    samples = Lists.newLinkedList();
    for (int i = 0; i < numSamples; i++) {
        samples.add(dataInput.readLong());
    }/* w  w  w  . j a v a 2 s. c o  m*/
}

From source file:org.locationtech.geogig.hooks.Hookables.java

public static List<CommandHook> findHooksFor(AbstractGeoGigOp<?> operation) {

    @SuppressWarnings("unchecked")
    final Class<? extends AbstractGeoGigOp<?>> clazz = (Class<? extends AbstractGeoGigOp<?>>) operation
            .getClass();/*  ww w. j av a 2  s  . c om*/

    List<CommandHook> hooks = Lists.newLinkedList();
    /*
     * First add any classpath hook, as they can be added to any command, regardless of having
     * the @Hookable annotation or not
     */
    for (CommandHook hook : classPathHooks) {
        if (hook.appliesTo(clazz)) {
            hooks.add(hook);
        }
    }

    /*
     * Now add any script hook that's configured for the operation iif it's @Hookable
     */
    final Optional<String> name = Hookables.getFilename(clazz);
    if (!name.isPresent()) {
        return hooks;
    }

    final File hooksDir = findHooksDirectory(operation);
    if (hooksDir == null) {
        return hooks;
    }

    if (name.isPresent()) {
        String preHookName = "pre_" + name.get().toLowerCase();
        String postHookName = "post_" + name.get().toLowerCase();
        File[] files = hooksDir.listFiles();
        for (File file : files) {
            String filename = file.getName();
            if (isHook(filename, preHookName)) {
                hooks.add(Scripting.createScriptHook(file, true));
            }
            if (isHook(filename, postHookName)) {
                hooks.add(Scripting.createScriptHook(file, false));
            }
        }
    }
    return hooks;

}

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

/**
 * Gets a list of all commands in all services.
 *//*from   ww w  . j a va 2s .  c  o  m*/
public List<Command> getAllCommands() {
    List<Command> allCommands = Lists.newLinkedList();

    Iterator<Service> sit = this.getServices().iterator();
    while (sit.hasNext()) {
        Service s = sit.next();
        Iterator<Command> cit = s.getCommands().iterator();
        while (cit.hasNext()) {
            Command c = cit.next();
            allCommands.add(c);
        }
    }

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

From source file:org.richfaces.tests.metamer.ftest.extension.configurator.config.SimpleConfig.java

public SimpleConfig(Object testInstance, Field f, Object value) {
    injectionsConfigurations = Lists.newLinkedList();
    add(testInstance, f, value);
}

From source file:com.romeikat.datamessie.core.base.util.publishedDates.loading.sequence.ListPublishedDateSequenceLoadingStrategy.java

@Override
protected List<T> initializeEmptyResult() {
    return Lists.newLinkedList();
}

From source file:org.apache.aurora.common.net.http.handlers.ContentionPrinter.java

private static List<String> getThreadInfo(ThreadInfo t, StackTraceElement[] stack) {
    List<String> lines = Lists.newLinkedList();

    lines.add(String.format("'%s' Id=%d %s", t.getThreadName(), t.getThreadId(), t.getThreadState()));
    lines.add("Waiting for lock: " + t.getLockName());
    lines.add("Lock is currently held by thread: " + t.getLockOwnerName());
    lines.add("Wait time: " + t.getBlockedTime() + " ms.");
    for (StackTraceElement s : stack) {
        lines.add(String.format("    " + s.toString()));
    }/*w w w .ja  v a 2  s .c om*/
    lines.add("\n");

    return lines;
}