List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:com.spoiledmilk.ibikecph.search.SearchListItem.java
public static int pointsForName(String name, String address, String srchString) { LinkedList<String> terms = new LinkedList<String>(); String srchStringSplit[] = srchString.split(" "); for (String str : srchStringSplit) { if (!terms.contains(str)) terms.add(str); }//w w w .j a va 2s. c o m int total = 0; int points = Util.numberOfOccurenciesOfString(name, srchString); if (points > 0) { total += points * POINTS_EXACT_NAME; } else { for (String str : terms) { points = Util.numberOfOccurenciesOfString(name, str); if (points > 0) { total += points * POINTS_PART_NAME; } } } points = Util.numberOfOccurenciesOfString(address, srchString); if (points > 0) { total += points * POINTS_EXACT_ADDRESS; } else { for (String str : terms) { points = Util.numberOfOccurenciesOfString(address, str); if (points > 0) { total += points * POINTS_PART_NAME; } } } return total; }
From source file:eu.stratosphere.pact.test.pactPrograms.TPCHQuery4ITCase.java
@Parameters public static Collection<Object[]> getConfigurations() { LinkedList<Configuration> tConfigs = new LinkedList<Configuration>(); Configuration config = new Configuration(); config.setInteger("TPCHQuery4Test#NoSubtasks", 4); tConfigs.add(config); return toParameterList(tConfigs); }
From source file:marytts.modules.ModuleRegistry.java
/** * A method for determining the list of modules required to transform * the given source data type into the requested target data type. If the * voice given is not null, any preferred modules it may have are taken into account. * @return the (ordered) list of modules required, or null if no such * list could be found.// w ww.j a va 2s . c o m * @throws IllegalStateException if called while registration is not yet complete. * @throws NullPointerException if source data type, target data type or locale is null. */ public static LinkedList<MaryModule> modulesRequiredForProcessing(MaryDataType sourceType, MaryDataType targetType, Locale locale, Voice voice) { if (!registrationComplete) throw new IllegalStateException("Cannot inquire about modules while registration is ongoing"); if (sourceType == null) throw new NullPointerException("Received null source type"); if (targetType == null) throw new NullPointerException("Received null target type"); //if (locale == null) // throw new NullPointerException("Received null locale"); LinkedList<MaryDataType> seenTypes = new LinkedList<MaryDataType>(); seenTypes.add(sourceType); return modulesRequiredForProcessing(sourceType, targetType, locale, voice, seenTypes); }
From source file:net.dv8tion.jda.core.MessageHistory.java
public static RestAction<MessageHistory> getHistoryAround(MessageChannel channel, final String markerMessageId, int limit) { if (markerMessageId == null) throw new IllegalArgumentException("Provided markedMessageId cannot be null!"); if (limit > 100 || limit < 1) throw new IllegalArgumentException( "Provided limit was out of bounds. Minimum: 1, Max: 100. Provided: " + limit); Route.CompiledRoute route = Route.Messages.GET_MESSAGE_HISTORY_AROUND.compile(channel.getId(), Integer.toString(limit), markerMessageId); return new RestAction<MessageHistory>(channel.getJDA(), route, null) { @Override//w ww.j a v a 2 s . c o m protected void handleResponse(Response response, Request request) { if (!response.isOk()) request.onFailure(response); MessageHistory mHistory = new MessageHistory(channel); mHistory.markerId = markerMessageId; EntityBuilder builder = EntityBuilder.get(api); LinkedList<Message> msgs = new LinkedList<>(); JSONArray historyJson = response.getArray(); for (int i = 0; i < historyJson.length(); i++) msgs.add(builder.createMessage(historyJson.getJSONObject(i))); msgs.forEach(msg -> mHistory.history.put(msg.getId(), msg)); request.onSuccess(mHistory); } }; }
From source file:edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression.java
private final static void addFD(Collection<FunctionalDependency> fds, LogicalVariable var1, LogicalVariable var2) { LinkedList<LogicalVariable> set1 = new LinkedList<LogicalVariable>(); set1.add(var1); LinkedList<LogicalVariable> set2 = new LinkedList<LogicalVariable>(); set2.add(var2); FunctionalDependency fd1 = new FunctionalDependency(set1, set2); fds.add(fd1);//from w w w. j a v a2 s .co m }
From source file:fr.ericlab.util.Util.java
static public LinkedList<String> readStopWords(String pathToStopwordsFile) { LinkedList<String> stopWords = new LinkedList<>(); if (pathToStopwordsFile != null) { LineIterator it = null;//ww w . ja v a 2 s . c om try { it = FileUtils.lineIterator(new File(pathToStopwordsFile), "UTF-8"); while (it.hasNext()) { stopWords.add(it.nextLine()); } } catch (IOException ex) { Logger.getLogger(MABED.class.getName()).log(Level.SEVERE, null, ex); } finally { LineIterator.closeQuietly(it); } } return stopWords; }
From source file:com.scit.sling.test.MockResourceFactory.java
private static MockResourceResolver addResource(ResourceNode baseNode, MockResource baseResource, MockResourceResolver resolver) { LinkedList<Resource> children = new LinkedList<Resource>(); for (ResourceNode child : baseNode.getChildren()) { MockResource childResource = buildResource(resolver, child); resolver.addResource(childResource); children.add(childResource); addResource(child, childResource, resolver); }// ww w. j a va2 s . c o m resolver.addResource(baseResource); resolver.addChildren(baseResource, children); return resolver; }
From source file:eu.stratosphere.pact.test.failingPrograms.TaskFailureITCase.java
/** * {@inheritDoc}// w w w .ja va 2 s . c o m * * @return * @throws FileNotFoundException * @throws IOException */ @Parameters public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException { LinkedList<Configuration> testConfigs = new LinkedList<Configuration>(); Configuration config = new Configuration(); config.setInteger("MapTest#NoSubtasks", 4); testConfigs.add(config); return toParameterList(TaskFailureITCase.class, testConfigs); }
From source file:edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression.java
private final static void getFDsAndEquivClassesForEqWithConstant(ConstantExpression c, VariableReferenceExpression v, Collection<FunctionalDependency> fds, Map<LogicalVariable, EquivalenceClass> equivClasses) { LogicalVariable var = v.getVariableReference(); LinkedList<LogicalVariable> head = new LinkedList<LogicalVariable>(); // empty set in the head LinkedList<LogicalVariable> tail = new LinkedList<LogicalVariable>(); tail.add(var); FunctionalDependency fd = new FunctionalDependency(head, tail); fds.add(fd);//ww w. ja va2s . com EquivalenceClass ec = equivClasses.get(var); if (ec == null) { LinkedList<LogicalVariable> members = new LinkedList<LogicalVariable>(); members.add(var); EquivalenceClass eclass = new EquivalenceClass(members, c); equivClasses.put(var, eclass); } else { if (ec.representativeIsConst()) { ILogicalExpression c1 = ec.getConstRepresentative(); if (!c1.equals(c)) { // here I could also rewrite to FALSE return; } } ec.setConstRepresentative(c); } }
From source file:Utils.java
/** * Renders multiple paragraphs of text in an array to an image (created and returned). * * @param font The font to use// w w w . ja v a 2 s .c om * @param textColor The color of the text * @param text The message in an array of strings (one paragraph in each * @param width The width the text should be limited to * @return An image with the text rendered into it */ public static BufferedImage renderTextToImage(Font font, Color textColor, String text[], int width) { LinkedList<BufferedImage> images = new LinkedList<BufferedImage>(); int totalHeight = 0; for (String paragraph : text) { BufferedImage paraImage = renderTextToImage(font, textColor, paragraph, width); totalHeight += paraImage.getHeight(); images.add(paraImage); } BufferedImage image = createCompatibleImage(width, totalHeight); Graphics2D graphics = (Graphics2D) image.createGraphics(); int y = 0; for (BufferedImage paraImage : images) { graphics.drawImage(paraImage, 0, y, null); y += paraImage.getHeight(); } graphics.dispose(); return image; }