List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:org.cocos2dx.lib.Cocos2dxBitmap.java
private static LinkedList<String> divideStringWithMaxWidth(Paint paint, String content, int width) { int charLength = content.length(); int start = 0; int tempWidth = 0; LinkedList<String> strList = new LinkedList<String>(); /*/*from ww w. j a v a 2s .co m*/ * Break a String into String[] by the width & should wrap the word */ for (int i = 1; i <= charLength; ++i) { tempWidth = (int) Math.ceil(paint.measureText(content, start, i)); if (tempWidth >= width) { int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" "); if (lastIndexOfSpace != -1 && lastIndexOfSpace > start) { /** * Should wrap the word */ strList.add(content.substring(start, lastIndexOfSpace)); i = lastIndexOfSpace; } else { /* * Should not exceed the width */ if (tempWidth > width) { strList.add(content.substring(start, i - 1)); /* * compute from previous char */ --i; } else { strList.add(content.substring(start, i)); } } // remove spaces at the beginning of a new line while (content.indexOf(i++) == ' ') { } start = i; } } /* * Add the last chars */ if (start < charLength) { strList.add(content.substring(start)); } return strList; }
From source file:com.cloudapi.cloud.rootadminhost.HostResponse.java
public Document id(String id) throws Exception { LinkedList<NameValuePair> arguments = newQueryValues("id", null); arguments.add(new NameValuePair("id", id)); return Request(arguments); }
From source file:com.espertech.esper.epl.core.ResultSetProcessorSimple.java
/** * Applies the select-clause to the given events returning the selected events. The number of events stays the * same, i.e. this method does not filter it just transforms the result set. * <p>/*from www.j a va2 s .c om*/ * Also applies a having clause. * @param exprProcessor - processes each input event and returns output event * @param events - input events * @param optionalHavingNode - supplies the having-clause expression * @param isNewData - indicates whether we are dealing with new data (istream) or old data (rstream) * @param isSynthesize - set to true to indicate that synthetic events are required for an iterator result set * @param exprEvaluatorContext context for expression evalauation * @return output events, one for each input event */ protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor, EventBean[] events, ExprEvaluator optionalHavingNode, boolean isNewData, boolean isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { if (events == null) { return null; } LinkedList<EventBean> result = new LinkedList<EventBean>(); EventBean[] eventsPerStream = new EventBean[1]; for (EventBean theEvent : events) { eventsPerStream[0] = theEvent; Boolean passesHaving = (Boolean) optionalHavingNode.evaluate(eventsPerStream, isNewData, exprEvaluatorContext); if ((passesHaving == null) || (!passesHaving)) { continue; } result.add(exprProcessor.process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext)); } if (!result.isEmpty()) { return result.toArray(new EventBean[result.size()]); } else { return null; } }
From source file:com.cloud.agent.resource.virtualnetwork.ConfigHelper.java
private static List<ConfigItem> generateConfig(VpnUsersCfgCommand cmd) { LinkedList<ConfigItem> cfg = new LinkedList<>(); for (VpnUsersCfgCommand.UsernamePassword userpwd : cmd.getUserpwds()) { String args = ""; if (!userpwd.isAdd()) { args += "-U "; args += userpwd.getUsername(); } else {/* w ww . java2s . c o m*/ args += "-u "; args += userpwd.getUsernamePassword(); } cfg.add(new ScriptConfigItem(VRScripts.VPN_L2TP, args)); } return cfg; }
From source file:edu.uci.ics.jung.graph.predicates.ConnectedGraphPredicate.java
/** * Returns <code>true</code> if there exists a path from each * vertex to all other vertices (ignoring edge direction). * /* w w w .j av a 2 s . c om*/ * <p>Returns <code>true</code> for an empty graph.</p> * * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object) */ public boolean evaluateGraph(ArchetypeGraph graph) { Graph g = (Graph) graph; if (g.numVertices() == 0) return true; Vertex start = (Vertex) g.getVertices().iterator().next(); // pick any vertex Set visited = new HashSet(); LinkedList stack = new LinkedList(); stack.add(start); // traverse through graph in depth-first order while (!stack.isEmpty()) { Vertex v = (Vertex) stack.removeFirst(); visited.add(v); Set neighbors = v.getNeighbors(); for (Iterator n_it = neighbors.iterator(); n_it.hasNext();) { Vertex w = (Vertex) n_it.next(); if (!visited.contains(w)) stack.addFirst(w); } } return (visited.size() == g.numVertices()); }
From source file:org.matsim.contrib.parking.parkingchoice.lib.GeneralLib.java
public static LinkedList<String> convertStringArrayToList(String[] array) { LinkedList<String> list = new LinkedList<String>(); for (int i = 0; i < array.length; i++) { String trimedString = array[i].trim(); if (trimedString.length() > 0) { list.add(trimedString); }/* www .j a v a 2s . c o m*/ } return list; }
From source file:jp.co.ctc_g.jse.vid.ViewId.java
private static void is(ViewId self, ViewIdStore store) { Args.checkNotNull(self);// w ww . ja v a2s .co m self.freeze(); synchronized (store.semaphore()) { LinkedList<ViewId> ids = store.find(); assert ids != null; if (ids.contains(self)) { int index = ids.indexOf(self); for (int i = ids.size() - 1; i > index; i--) { ids.remove(i); } if (OVERRIDE_THE_SAME_ONE) { ids.set(index, self); } } else { ids.add(self); } store.store(ids); } }
From source file:com.duck8823.dao.PersonDao.java
public List<Person> list() throws SQLException { ResultSet rs = dataSource.getConnection().createStatement().executeQuery("SELECT id, name FROM person"); LinkedList<Person> result = new LinkedList<>(); while (rs.next()) { result.add(new Person(rs.getLong("id"), rs.getString("name"))); }/* w ww . j a v a 2 s . c o m*/ return result; }
From source file:org.deegree.securityproxy.wfs.responsefilter.capabilities.WfsCapabilitiesModificationManagerCreator.java
private AttributeModificationRule createGetRule() { LinkedList<ElementPathStep> path = createBasePath(); path.add(new ElementPathStep(new QName("http://www.opengis.net/ows", "Get"))); return new AttributeModificationRule(getDcpUrl, path); }
From source file:org.deegree.securityproxy.wfs.responsefilter.capabilities.WfsCapabilitiesModificationManagerCreator.java
private AttributeModificationRule createPostRule() { LinkedList<ElementPathStep> path = createBasePath(); path.add(new ElementPathStep(new QName("http://www.opengis.net/ows", "Post"))); return new AttributeModificationRule(postDcpUrl, path); }