List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList()
From source file:org.apache.kylin.engine.spark.util.IteratorUtils.java
public static <K, V> Iterator<Tuple2<K, V>> merge(final Iterator<Tuple2<K, V>> input, final Comparator<K> comparator, final Function<Iterable<V>, V> converter) { return new Iterator<Tuple2<K, V>>() { Tuple2<K, V> current = input.hasNext() ? input.next() : null; @Override//from w w w .j a v a2s . c om public boolean hasNext() { return current != null; } @Override public Tuple2<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final LinkedList<V> values = Lists.newLinkedList(); K currentKey = current._1(); values.add(current._2()); while (input.hasNext()) { Tuple2<K, V> next = input.next(); if (comparator.compare(currentKey, next._1()) == 0) { values.add(next._2()); } else { current = next; try { return new Tuple2<>(currentKey, converter.call(values)); } catch (Exception e) { throw new RuntimeException(e); } } } if (!input.hasNext()) { current = null; } try { return new Tuple2<>(currentKey, converter.call(values)); } catch (Exception e) { throw new RuntimeException(e); } } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
From source file:bio.pih.genoogle.search.results.SearchResults.java
/** * @param params/*from www . j av a 2s . co m*/ */ public SearchResults(SearchParams params) { this.params = params; List<Hit> l = Lists.newLinkedList(); this.hits = Collections.synchronizedList(l); }
From source file:ratpack.handling.internal.ChainBuilders.java
private static <T> Handler create(Function<List<Handler>, ? extends T> toChainBuilder, Action<? super T> chainBuilderAction) throws Exception { List<Handler> handlers = Lists.newLinkedList(); T chainBuilder = toChainBuilder.apply(handlers); chainBuilderAction.execute(chainBuilder); return Handlers.chain(handlers.toArray(new Handler[handlers.size()])); }
From source file:integration.PerfectResultsIfOnlyEqualInputIsUsed.java
@Override public List<Usage> getTrainingData() { List<Usage> usages = Lists.newLinkedList(); usages.add(createUsage()); return usages; }
From source file:exec.examples.EventExamples.java
/** * 1: Find all users in the dataset./*from w ww . ja v a 2 s. c om*/ */ public static List<String> findAllUsers() { // This step is straight forward, as events are grouped by user. Each // .zip file in the dataset corresponds to one user. List<String> zips = Lists.newLinkedList(); for (File f : FileUtils.listFiles(new File(DIR_USERDATA), new String[] { "zip" }, true)) { zips.add(f.getAbsolutePath()); } return zips; }
From source file:org.richfaces.tests.metamer.ftest.extension.configurator.ConfiguratorUtils.java
public static List<Config> mergeConfigs(List<Config> list1, List<Config> list2) { List<Config> result = Lists.newLinkedList(); if (list1.isEmpty() && list2.isEmpty()) { return result; } else if (list1.isEmpty() || list2.isEmpty()) { result.addAll(list1);//from w w w . ja va 2s .c o m result.addAll(list2); } else { for (Config config1 : list1) { for (Config config2 : list2) { result.add(mergeTwoConfigs(config1, config2)); } } } return result; }
From source file:com.enonic.cms.core.portal.rendering.tracing.RenderTraceHistory.java
public RenderTraceHistory() { this.history = Lists.newLinkedList(); }
From source file:com.cloudera.dataflow.spark.CoderHelpers.java
/** * Utility method for serializing a Iterable of values using the specified coder. * * @param values Values to serialize.//w w w . ja v a 2 s. c o m * @param coder Coder to serialize with. * @return List of bytes representing serialized objects. */ static List<byte[]> toByteArrays(Iterable values, final Coder coder) { List<byte[]> res = Lists.newLinkedList(); for (Object value : values) { res.add(toByteArray(value, coder)); } return res; }
From source file:com.chiorichan.factory.StackFactory.java
public List<ScriptTraceElement> examineStackTrace(StackTraceElement[] stackTrace) { Validate.notNull(stackTrace);/*from w w w. j ava2 s . c o m*/ List<ScriptTraceElement> scriptTrace = Lists.newLinkedList(); for (StackTraceElement ste : stackTrace) if (ste.getFileName() != null && scriptStackHistory.containsKey(ste.getFileName())) scriptTrace.add(new ScriptTraceElement(scriptStackHistory.get(ste.getFileName()), ste)); ScriptingContext context = scriptStack.values().toArray(new ScriptingContext[0])[scriptStack.size() - 1]; if (context != null) { boolean contains = false; for (ScriptTraceElement ste : scriptTrace) if (ste.context().filename().equals(context.filename())) contains = true; if (!contains) scriptTrace.add(0, new ScriptTraceElement(context, "")); } return scriptTrace; }
From source file:org.geogit.storage.sqlite.PathToRootWalker.java
public PathToRootWalker(ObjectId start, SQLiteGraphDatabase<T> graph, T cx) { this.graph = graph; this.cx = cx; q = Lists.newLinkedList(); q.add(start);// w ww . j a v a 2 s . c o m seen = Sets.newHashSet(); }