List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList()
From source file:com.pradeep.blackjack.deck.Shoe.java
public Shoe(int numDecks, int stopDeal) { Preconditions.checkArgument(numDecks > 0, "Number of decks must be greater than 0. Given {}", numDecks); Preconditions.checkArgument(stopDeal >= 0 && stopDeal < numDecks * 52, "Can't remove stop deal before the first card"); this.cards = Lists.newLinkedList(); // Construct n decks and add the cards to the shoe for (int i = 0; i < numDecks; i++) { Deck d = new Deck(); for (ICard card : d) { this.cards.add(card); }//w w w.j a v a 2 s. co m } this.stopDeal = stopDeal; }
From source file:ru.frostman.web.aop.AopEnhancer.java
public static void enhance(CtClass ctClass, List<MethodInterceptor> methodInterceptors) { try {// w ww. j ava 2s . c om for (CtMethod method : ctClass.getDeclaredMethods()) { if (method.getAnnotation(Interceptor.class) != null) { continue; } List<MethodInterceptor> interceptors = Lists.newLinkedList(); for (MethodInterceptor interceptor : methodInterceptors) { if (interceptor.matches(method)) { interceptors.add(interceptor); } } if (interceptors.size() == 0) { continue; } CtMethod wrappedMethod = new CtMethod(method, ctClass, null); String wrappedName = "$javin$" + method.getName(); wrappedMethod.setName(wrappedName); ctClass.addMethod(wrappedMethod); StringBuilder body = new StringBuilder("{"); body.append(METHOD_INVOCATION).append(" mi = new ").append(METHOD_INVOCATION).append("(") .append("\"").append(ctClass.getName()).append("\", "); if (Modifier.isStatic(method.getModifiers())) { body.append("null"); } else { body.append("$0"); } body.append(", \"").append(method.getName()).append("\", new Class"); CtClass[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 0) { body.append("[]{"); int i = 0; for (CtClass argType : parameterTypes) { body.append(argType.getName()).append(".class"); if (i < parameterTypes.length - 1) { body.append(", "); } i++; } body.append("}"); } else { body.append("[0]"); } body.append(", $args, new ").append(METHOD_INTERCEPTOR).append("[]{"); int i = 0; for (MethodInterceptor methodInterceptor : interceptors) { body.append(METHOD_INTERCEPTORS).append(".getInterceptor(\"") .append(methodInterceptor.getName()).append("\")"); if (i < interceptors.size() - 1) { body.append(", "); } i++; } body.append("});"); if (!method.getReturnType().equals(CtClass.voidType)) { body.append("return "); } body.append("($r) mi.proceed();}"); method.setBody(body.toString()); } } catch (Exception e) { throw new AopException("Exception while aop enhancing: " + ctClass, e); } }
From source file:org.apache.aurora.scheduler.scheduling.TaskGroup.java
@VisibleForTesting public TaskGroup(TaskGroupKey key, String initialTaskId) { this.key = key; this.penaltyMs = 0; this.tasks = Lists.newLinkedList(); this.tasks.add(initialTaskId); }
From source file:cc.recommenders.io.Logger.java
public static void reset() { log = Lists.newLinkedList(); isCapturing = false; isPrinting = false; isDebugging = false; }
From source file:cc.gospy.plugin.proxy.HttpProxy.java
private HttpProxy(InetSocketAddress address, int responseTime) { this.address = address; this.averageResponseTime = responseTime; this.visitCount = 1; this.history = Lists.newLinkedList(); for (int i = 0; i < historyDepth; i++) { history.addFirst(true);//from www. j a va 2 s . c om } }
From source file:org.gradle.internal.operations.DefaultOperationQueue.java
DefaultOperationQueue(ExecutorService executor, OperationWorker<T> worker) { this.executor = MoreExecutors.listeningDecorator(executor); this.worker = worker; this.operations = Lists.newLinkedList(); }
From source file:org.apache.kylin.storage.hbase.common.coprocessor.AggrKey.java
AggrKey(byte[] groupByMask) { this.groupByMask = groupByMask; LinkedList<Integer> list = Lists.newLinkedList(); for (int i = 0; i < groupByMask.length; i++) { if (groupByMask[i] != 0) { list.add(i);//from w w w. ja v a2s .c o m } } groupByMaskSet = new int[list.size()]; for (int i = 0; i < list.size(); i++) { groupByMaskSet[i] = list.get(i); } }
From source file:org.artifactory.api.callhome.FeatureGroup.java
public void addFeature(FeatureGroup featureGroup) { if (features == null) features = Lists.newLinkedList(); features.add(featureGroup); }
From source file:com.enonic.cms.core.resource.ResourceKey.java
private static String[] normalize(final String[] parts) { final LinkedList<String> normalized = Lists.newLinkedList(); for (final String part : parts) { if (part.equals(".")) { continue; }//from w w w.j a va 2 s . c o m if (part.equals("..")) { if (!normalized.isEmpty()) { normalized.removeLast(); } continue; } normalized.add(part); } return Iterables.toArray(normalized, String.class); }
From source file:com.google.test.metric.report.chart.HistogramChartUrl.java
public void setYMark(int min, int max, Function<Integer, Double> scalingFunction) { keys.put("chxt", "y"); if (scalingFunction instanceof Logarithmic) { List<String> yLabels = Lists.newLinkedList(); List<String> yPositions = Lists.newLinkedList(); double scaledMax = scalingFunction.apply(max); for (int labelExponent = 0; pow(10, labelExponent) < max; labelExponent++) { yLabels.add(String.valueOf((int) pow(10, labelExponent))); yPositions.add(String.valueOf(100 * (labelExponent + 1) / scaledMax)); }/*from w w w.ja va 2 s.co m*/ keys.put("chxl", "0:|" + toList("|", yLabels.toArray(new String[yLabels.size()]))); keys.put("chxp", "0," + toList(",", yPositions.toArray(new String[yPositions.size()]))); } else { keys.put("chxr", format("0,%d,%d", min, max)); } }