List of usage examples for java.util LinkedList contains
public boolean contains(Object o)
From source file:vn.chodientu.component.imboclient.ImboClient.java
/** * Parse server host URLs and prepare them for usage * * @param hosts URLs for the Imbo server * @return Array of URLs//from w w w .j ava2 s . c om */ private String[] parseUrls(String[] hosts) { LinkedList<String> urls = new LinkedList<String>(); for (String host : hosts) { host = normalizeUrl(host); if (host != null && !urls.contains(host)) { urls.add(host); } } return urls.toArray(new String[urls.size()]); }
From source file:specminers.smartic.MergingBlock.java
public List<State<String>> getNodesByBreadthFirstSearch(Automaton<String> automaton) { LinkedList<State<String>> V = new LinkedList<>(); Queue<State<String>> Q = new LinkedBlockingDeque<>(); V.add(automaton.getInitialState());/*from w w w .ja va 2 s . c om*/ Q.add(automaton.getInitialState()); while (!Q.isEmpty()) { State<String> t = Q.poll(); for (Step<String> delta : automaton.getDelta().get(t)) { State<String> u = delta.getDestination(); if (!V.contains(u)) { V.add(u); Q.add(u); } } } return V; }
From source file:org.metaservice.core.deb.util.GitCache.java
public void runDiscovery() { HashSet<String> parsed = new HashSet<>(); LinkedList<String> toParse = new LinkedList<>(); HashSet<String> dists = new HashSet<>(); toParse.add(startString);/* w w w .j a v a 2 s . c om*/ while (toParse.size() > 0) { String uri = toParse.pop(); try { String s = clientMetaservice.get(uri); if (s == null) { LOGGER.error("Couldn't load " + uri + " skipping."); continue; } Document document = Jsoup.parse(s, uri); parsed.add(uri); for (Element e : document.select("a:contains(next change)")) { String href = e.attr("abs:href"); if (!parsed.contains(href) && !toParse.contains(href)) { LOGGER.info("adding (next) ", href); toParse.push(href); } } for (Element e : document.select("a[href$=/]")) { String absHref = e.attr("abs:href"); String href = e.attr("href"); if (!dists.contains(href) && !href.startsWith("/") && !href.startsWith(".") /* &&!toParse.contains (href) */) { if (uri.endsWith("dists/") /*&& !href.contains("sid") && !href.contains("experimental")*/) { dists.add(href); LOGGER.info(href); for (String license : licenses) { String url = absHref + license + "/"; LOGGER.info("adding (lic) {}", url); toParse.add(url); } } for (String license : licenses) { if (uri.endsWith(license + "/")) { if (href.startsWith("binary-")) { for (String arch : archs) { if (href.contains(arch)) { LOGGER.info("adding (archdir) {}", absHref); toParse.add(absHref); } } } if (href.startsWith("source")) { LOGGER.info("adding (archdir) {}", absHref); toParse.add(absHref); } } } } } for (Element e : document.select("a[abs:href$=Packages.gz] , a[abs:href$=Sources.gz]")) { String href = e.attr("abs:href"); //only if this seems to be a non duplicate if (document.select("a:contains(prev change)").size() == 0 || document.select("a:contains(prev change)").get(0).attr("abs:href").equals(document .select("a:contains(prev):not(:contains(change))").get(0).attr("abs:href"))) { LOGGER.info("RESULT processing ... {} {} ", i++, href); processFileToParse(href); } } } catch (RuntimeException exception) { LOGGER.error("RUNTIME EXCEPTION ", exception); throw exception; } } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaGroupTable.java
/** * Attention: this method is copied from the parent class: {@link Table#setColumnOrder(java.lang.Object[])} *//*w ww.j a v a 2s . com*/ public void setColumnOrder(Object[] columnOrder) { if (columnOrder == null || !isColumnReorderingAllowed()) { return; } final LinkedList<Object> newOrder = new LinkedList<>(); for (Object aColumnOrder : columnOrder) { if (aColumnOrder != null && visibleColumns.contains(aColumnOrder)) { visibleColumns.remove(aColumnOrder); newOrder.add(aColumnOrder); } } for (final Object columnId : visibleColumns) { if (!newOrder.contains(columnId)) { newOrder.add(columnId); } } visibleColumns = newOrder; // Assure visual refresh refreshRowCache(); }
From source file:org.gephi.statistics.plugin.ConnectedComponents.java
private void tarjans(AttributeColumn col, LinkedList<Node> S, HierarchicalDirectedGraph hgraph, Node f, int[] index, int[] low_index, HashMap<Node, Integer> indicies) { int id = indicies.get(f); index[id] = count;//from w ww .j a v a 2 s .c o m low_index[id] = count; count++; S.addFirst(f); EdgeIterable edgeIter = hgraph.getOutEdgesAndMetaOutEdges(f); for (Edge e : edgeIter) { Node u = hgraph.getOpposite(f, e); int x = indicies.get(u); if (index[x] == 0) { tarjans(col, S, hgraph, u, index, low_index, indicies); low_index[id] = Math.min(low_index[x], low_index[id]); } else if (S.contains(u)) { low_index[id] = Math.min(low_index[id], index[x]); } } if (low_index[id] == index[id]) { Node v = null; while (v != f) { v = S.removeFirst(); AttributeRow row = (AttributeRow) v.getNodeData().getAttributes(); row.setValue(col, stronglyCount); } stronglyCount++; } }
From source file:org.pocketcampus.plugin.moodle.server.old.MoodleServiceImpl.java
private LinkedList<String> getAllFilesFromMoodleResource(String resourceUrl, Cookie cookie) { LinkedList<String> urls = new LinkedList<String>(); HttpPageReply httpReply = null;//from w ww . j a va2 s. co m try { httpReply = getHttpReplyWithCookie(resourceUrl, cookie); } catch (IOException e) { e.printStackTrace(); return urls; // failed, do not crash } if (httpReply.getPage() != null) { for (MoodleResource j : getLinks(httpReply.getPage())) { if (j.getIUrl().indexOf("/pluginfile.php/") != -1) if (!urls.contains(j.getIUrl())) urls.add(stripOffQueryString(j.getIUrl())); } } else if (httpReply.getLocation() != null) { if (httpReply.getLocation().indexOf("/pluginfile.php/") != -1) urls.add(stripOffQueryString(httpReply.getLocation())); } else { System.out.println("error while processing " + resourceUrl); } return urls; }
From source file:com.feilong.core.bean.ConvertUtilTest.java
/** * To t test.//from www .jav a 2 s . c o m */ @Test public void testConvert() { String[] tokenizeToStringArray = StringUtil.tokenizeToStringArray("6", "_"); LinkedList<Serializable> linkedList = new LinkedList<Serializable>(); for (String string : tokenizeToStringArray) { Serializable t = ConvertUtil.convert(string, Serializable.class); LOGGER.debug(t.getClass().getCanonicalName()); linkedList.add(t); } Serializable l = 6L; LOGGER.debug("linkedList:{},contains:{},{}", linkedList, l, linkedList.contains(l)); }
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java
private void dispatchObjectEventControls(ObjectEvent objectEvent) { List<Control> cursors = null; synchronized (cursorHandler) { cursors = cursorHandler.getCursors(); }//from ww w . j a v a 2 s. c o m Control activeControl = null; LinkedList<ObjectObserverEvent> consumedOoes = new LinkedList<ObjectObserverEvent>(); ListIterator<Control> listIterator = controls.listIterator(controls.size()); while (listIterator.hasPrevious()) { Control control = listIterator.previous(); if ((!control.isVisible()) || (cursors.contains(control))) { continue; } ObjectEvent copiedObjectEvent = objectEvent.copy(); // check how many of Ooes are within this control LinkedList<ObjectObserverEvent> ooes = new LinkedList<ObjectObserverEvent>(); for (ObjectObserverEvent ooe : objectEvent.getObjectObserverEvents()) { if (!consumedOoes.contains(ooe)) { if (control.isWithin(new Point(ooe.getX(), ooe.getY()))) { ooes.add(ooe); consumedOoes.add(ooe); } } } copiedObjectEvent.setObjectObserverEvents(ooes); ObjectObserverEvent targetOoe = objectEvent.getTargetObjectObserverEvent(); if (ooes.contains(targetOoe)) { activeControl = control; } else { targetOoe = null; } copiedObjectEvent.setTargetObjectObserverEvent(targetOoe); //log.debug("Ooes: "+ooes.size()); if (ooes.size() > 0) { log.debug(control.getClass().toString() + "[" + control.getPosition().toString() + "]" + ": Sending " + ooes.size() + " ooes"); control.dispatchEvent(copiedObjectEvent); } } if ((activeControl != null) && (!activeControl.equals(backgroundControl))) { if (!activeControl.equals(controls.getLast())) { controls.remove(activeControl); controls.add(activeControl); } } }
From source file:com.wordnik.swaggersocket.server.SwaggerSocketProtocolInterceptor.java
private final void attachWriter(final AtmosphereResource r) { final AtmosphereRequest request = r.getRequest(); AtmosphereResponse res = r.getResponse(); AsyncIOWriter writer = res.getAsyncIOWriter(); BlockingQueue<AtmosphereResource> queue = (BlockingQueue<AtmosphereResource>) getContextValue(request, SUSPENDED_RESPONSE);/* w ww . j av a 2 s.co m*/ if (queue == null) { queue = new LinkedBlockingQueue<AtmosphereResource>(); request.getSession().setAttribute(SUSPENDED_RESPONSE, queue); } if (AtmosphereInterceptorWriter.class.isAssignableFrom(writer.getClass())) { // WebSocket already had one. if (r.transport() != AtmosphereResource.TRANSPORT.WEBSOCKET) { writer = new AtmosphereInterceptorWriter() { @Override protected void writeReady(AtmosphereResponse response, byte[] data) throws IOException { // We are buffering response. if (data == null) return; BlockingQueue<AtmosphereResource> queue = (BlockingQueue<AtmosphereResource>) getContextValue( request, SUSPENDED_RESPONSE); if (queue != null) { AtmosphereResource resource; try { // TODO: Should this be configurable // We stay suspended for 60 seconds resource = queue.poll(60, TimeUnit.SECONDS); } catch (InterruptedException e) { logger.trace("", e); return; } if (resource == null) { logger.debug("No resource was suspended, resuming the second connection."); } else { logger.trace("Resuming {}", resource.uuid()); try { OutputStream o = resource.getResponse().getResponse().getOutputStream(); o.write(data); o.flush(); resource.resume(); } catch (IOException ex) { logger.warn("", ex); } } } else { logger.error("Queue was null"); } } /** * Add an {@link AsyncIOInterceptor} that will be invoked in the order it was added. * * @param filter {@link AsyncIOInterceptor * @return this */ public AtmosphereInterceptorWriter interceptor(AsyncIOInterceptor filter) { if (!filters.contains(filter)) { filters.addLast(filter); } return this; } }; res.asyncIOWriter(writer); } //REVIST need a better way to add a custom filter at the first entry and not at the last as // e.g. interceptor(AsyncIOInterceptor interceptor, int position) LinkedList<AsyncIOInterceptor> filters = AtmosphereInterceptorWriter.class.cast(writer).filters(); if (!filters.contains(interceptor)) { filters.addFirst(interceptor); } } }