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.gradoop.flink.io.impl.tlf.functions.EdgeLabelList.java

@Override
public void flatMap(GraphTransaction graphTransaction, Collector<List<String>> collector) throws Exception {
    List<String> list = Lists.newLinkedList();
    for (Edge edge : graphTransaction.getEdges()) {
        list.add(edge.getLabel());//from   w  w w.j a  va  2  s  .  c  om
    }
    collector.collect(list);
}

From source file:org.gradoop.flink.io.impl.tlf.functions.VertexLabelList.java

@Override
public void flatMap(GraphTransaction graphTransaction, Collector<List<String>> collector) throws Exception {
    List<String> list = Lists.newLinkedList();
    for (Vertex vertex : graphTransaction.getVertices()) {
        list.add(vertex.getLabel());//  w w  w  .j a v a  2s  .c om
    }
    collector.collect(list);
}

From source file:org.immutables.check.ObjectChecker.java

static StackTraceElement[] trimStackTrace(StackTraceElement[] stackTrace) {
    LinkedList<StackTraceElement> list = Lists.newLinkedList();
    for (int i = stackTrace.length - 1; i >= 0; i--) {
        StackTraceElement s = stackTrace[i];
        if (s.getClassName().startsWith(Checkers.class.getPackage().getName())) {
            break;
        }/*from w w w .ja v a  2  s .c o m*/
        list.addLast(s);
    }
    return list.toArray(new StackTraceElement[list.size()]);
}

From source file:com.chen.mail.utils.DequeMap.java

/**
 * Add a value V to the deque stored under key K.
 *
 *///from   w w  w  .  j a v a2 s.com
public void add(K key, V item) {
    Deque<V> pile = mMap.get(key);
    if (pile == null) {
        pile = Lists.newLinkedList();
        mMap.put(key, pile);
    }
    pile.add(item);
}

From source file:com.continuuity.loom.layout.change.ClusterLayoutTracker.java

/**
 * Create a layout change tracker given some starting layout.
 *
 * @param startingLayout starting layout of the cluster.
 *///  w  ww  .  j a v a  2  s  .c  o  m
public ClusterLayoutTracker(ClusterLayout startingLayout) {
    this.changes = Lists.newLinkedList();
    this.states = Lists.newLinkedList();
    this.states.add(startingLayout);
}

From source file:org.apache.drill.exec.store.schedule.AffinityCreator.java

public static <T extends CompleteWork> List<EndpointAffinity> getAffinityMap(List<T> work) {
    Stopwatch watch = new Stopwatch();

    long totalBytes = 0;
    for (CompleteWork entry : work) {
        totalBytes += entry.getTotalBytes();
    }// w ww.  j ava 2  s . c o  m

    ObjectFloatOpenHashMap<DrillbitEndpoint> affinities = new ObjectFloatOpenHashMap<DrillbitEndpoint>();
    for (CompleteWork entry : work) {
        for (ObjectLongCursor<DrillbitEndpoint> cursor : entry.getByteMap()) {
            long bytes = cursor.value;
            float affinity = (float) bytes / (float) totalBytes;
            logger.debug("Work: {} Endpoint: {} Bytes: {}", work, cursor.key.getAddress(), bytes);
            affinities.putOrAdd(cursor.key, affinity, affinity);
        }
    }

    List<EndpointAffinity> affinityList = Lists.newLinkedList();
    for (ObjectFloatCursor<DrillbitEndpoint> d : affinities) {
        logger.debug("Endpoint {} has affinity {}", d.key.getAddress(), d.value);
        affinityList.add(new EndpointAffinity(d.key, d.value));
    }

    logger.debug("Took {} ms to get operator affinity", watch.elapsed(TimeUnit.MILLISECONDS));
    return affinityList;
}

From source file:bio.pih.genoogle.search.results.Hit.java

/**
 * @param id//from  w w  w .j  a  v  a 2 s.c o m
 * @param gi 
 * @param description
 * @param accession
 * @param hitLength
 * @param databankName
 */
public Hit(String id, String gi, String description, String accession, int hitLength, String databankName) {
    this.id = id;
    this.gi = gi;
    this.accession = accession;
    this.description = description;
    this.length = hitLength;
    this.databankName = databankName;
    this.hsps = Lists.newLinkedList();
}

From source file:com.facebook.buck.graph.AbstractBreadthFirstTraversal.java

public AbstractBreadthFirstTraversal(Iterable<? extends Node> initialNodes) {
    toExplore = Lists.newLinkedList();
    Iterables.addAll(toExplore, initialNodes);
    explored = Sets.newHashSet();/*from  ww  w .j a v  a  2  s.co m*/
}

From source file:org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser.java

public static List<byte[]> parseMessages(final String c) {
    final String content = clearWhiteSpaceToUpper(c);
    final int sixteen = 16;
    final int four = 4;
    // search for 16 FFs

    final List<byte[]> messages = Lists.newLinkedList();
    int idx = content.indexOf(FF_16, 0);
    while (idx > -1) {
        // next 2 bytes are length
        final int lengthIdx = idx + sixteen * 2;
        final int messageIdx = lengthIdx + four;
        final String hexLength = content.substring(lengthIdx, messageIdx);
        final byte[] byteLength = BaseEncoding.base16().decode(hexLength);
        final int length = ByteArray.bytesToInt(byteLength);
        final int messageEndIdx = idx + length * 2;

        // Assert that message is longer than minimum 19(header.length == 19)
        // If length in BGP message would be 0, loop would never end
        Preconditions.checkArgument(length >= MINIMAL_LENGTH,
                "Invalid message at index " + idx + ", length atribute is lower than " + MINIMAL_LENGTH);

        final String hexMessage = content.substring(idx, messageEndIdx);
        final byte[] message = BaseEncoding.base16().decode(hexMessage);
        messages.add(message);// w  w  w.j a v  a2 s  .  c om
        idx = messageEndIdx;
        idx = content.indexOf(FF_16, idx);
    }
    LOG.info("Succesfully extracted {} messages", messages.size());
    return messages;
}

From source file:org.apache.crunch.impl.mr.plan.NodePath.java

public NodePath(PCollectionImpl<?> tail) {
    this.path = Lists.newLinkedList();
    this.path.add(tail);
}