List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:markov.java
private static List<Character> string2List(String s) { LinkedList<Character> list = new LinkedList<Character>(); for (int c = 0; c < s.length(); c++) { list.add(s.charAt(c)); }//from w ww. j a va 2 s. c o m return list; }
From source file:de.hasait.genesis.base.freemarker.FreemarkerModelWriter.java
static void write(final Configuration pConfiguration, final Writer pWriter, final Object pModel, final Map pParams) throws IOException, TemplateException { final Map<Class<?>, Template> templateCache = TEMPLATE_CACHE.get(); Class<?> currentType = pModel.getClass(); Template template = templateCache.get(currentType); if (template == null) { final LinkedList<TypeNode> queue = new LinkedList<TypeNode>(); queue.add(new TypeNode(null, currentType)); TemplateNotFoundException firstE = null; do {/*w w w . ja v a2 s . c om*/ // take first from queue TypeNode current = queue.removeFirst(); currentType = current._type; // determine template template = templateCache.get(currentType); if (template == null) { final String templateName = currentType.getSimpleName() + ".ftl"; try { template = pConfiguration.getTemplate(templateName); } catch (final TemplateNotFoundException e) { if (firstE == null) { firstE = e; } } } if (template != null) { // fill cache including parents templateCache.put(currentType, template); while (true) { templateCache.put(currentType, template); current = current._parent; if (current == null) { break; } currentType = current._type; } } else { // fill queue with next nodes for (final Class<?> interfaceType : currentType.getInterfaces()) { queue.add(new TypeNode(current, interfaceType)); } final Class<?> superclassType = currentType.getSuperclass(); if (superclassType != null) { queue.add(new TypeNode(current, superclassType)); } } } while (template == null && !queue.isEmpty()); if (template == null) { throw firstE; } } write(pConfiguration, pWriter, template, pModel, pParams); }
From source file:com.github.jknack.amd4j.Amd4j.java
/** * Resolve a candidate uri to an existing uri. We need this bc, dependencies might or mightn't * have a file extension, or they might have a '.' in the file's name. * * @param loader The resource loader./* ww w . jav a 2s. c o m*/ * @param uri The candidate uri. * @return An existing uri for the candidate uri. * @throws IOException If the uri can't be resolved. */ private static ResourceURI resolve(final ResourceLoader loader, final ResourceURI uri) throws IOException { String path = uri.getPath(); LinkedList<ResourceURI> candidates = new LinkedList<ResourceURI>(); candidates.add(uri); ResourceURI alternative = ResourceURI.create(uri.toString() + ".js"); if (isEmpty(getExtension(path))) { candidates.addFirst(alternative); } else { candidates.addLast(alternative); } for (ResourceURI candidate : candidates) { if (loader.exists(candidate)) { return candidate; } } // force a file not found exception throw new FileNotFoundException(uri.toString()); }
From source file:eu.stratosphere.pact.test.pactPrograms.EnumTrianglesITCase.java
@Parameters public static Collection<Object[]> getConfigurations() { LinkedList<Configuration> tConfigs = new LinkedList<Configuration>(); Configuration config = new Configuration(); config.setInteger("EnumTrianglesTest#NoSubtasks", 4); tConfigs.add(config); return toParameterList(tConfigs); }
From source file:com.projity.algorithm.SelectFrom.java
public static LinkedList listInstance(SelectFrom a) { LinkedList list = new LinkedList(); list.add(a); return list;//w ww . j av a 2s . c om }
From source file:Main.java
public static List<Element> getChildElements(String tagName, Element element) { LinkedList<Element> result = new LinkedList<>(); NodeList nl = element.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i);//from w w w . j a v a 2 s .c o m if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals(tagName)) { result.add((Element) n); } } return result; }
From source file:com.projity.algorithm.SelectFrom.java
public static LinkedList listInstance(SelectFrom a, SelectFrom b) { LinkedList list = new LinkedList(); list.add(a); list.add(b);/*www . ja v a2 s .c o m*/ return list; }
From source file:com.projity.algorithm.SelectFrom.java
public static LinkedList listInstance(SelectFrom a, SelectFrom b, SelectFrom c) { LinkedList list = new LinkedList(); list.add(a); list.add(b);//from w w w .ja v a 2 s .com list.add(c); return list; }
From source file:com.projity.algorithm.SelectFrom.java
public static LinkedList listInstance(SelectFrom a, SelectFrom b, SelectFrom c, SelectFrom d) { LinkedList list = new LinkedList(); list.add(a); list.add(b);//from ww w .ja va2 s.c o m list.add(c); list.add(d); return list; }
From source file:eu.stratosphere.pact.test.pactPrograms.PairwiseSPITCase.java
@Parameters public static Collection<Object[]> getConfigurations() { LinkedList<Configuration> tConfigs = new LinkedList<Configuration>(); Configuration config = new Configuration(); config.setInteger("All2AllSPTest#NoSubtasks", 4); tConfigs.add(config); return toParameterList(tConfigs); }