List of usage examples for java.util LinkedList addAll
public boolean addAll(Collection<? extends E> c)
From source file:com.android.madpausa.cardnotificationviewer.ConcreteNotificationListenerService.java
/** * removes all clearable notifications from the service *//*from w w w . j a v a 2 s. c om*/ public void clearNotificationList() { LinkedList<StatusBarNotification> nCollection = new LinkedList<>(archivedNotificationMap.values()); nCollection.addAll(notificationMap.values()); for (StatusBarNotification sbn : nCollection) { if (sbn.isClearable()) { //remove notificaion from this service removeServiceNotification(sbn); //tells the system to cancel the notification cancelNotification(sbn); } } }
From source file:com.cyclopsgroup.waterview.web.RuntimeTreeNode.java
/** * Get node or child node by id/*from ww w. ja v a 2 s .c om*/ * * @param nodeId Node id * @return Node or null if not found */ public RuntimeTreeNode getNodeById(String nodeId) { LinkedList buffer = new LinkedList(); buffer.addLast(this); while (!buffer.isEmpty()) { RuntimeTreeNode node = (RuntimeTreeNode) buffer.removeFirst(); if (StringUtils.equals(nodeId, node.getNodeId())) { return node; } buffer.addAll(node.children.values()); } return null; }
From source file:de.dkfz.roddy.config.Configuration.java
public List<ConfigurationLoadError> getListOfLoadErrors() { LinkedList<ConfigurationLoadError> errors = new LinkedList<>(); for (Configuration c : parents) { errors.addAll(c.getListOfLoadErrors()); }/* w ww . ja v a2 s . com*/ errors.addAll(listOfLoadErrors); return errors; }
From source file:info.debatty.jinu.CaseResult.java
/** * * @return/*from w w w . j a v a 2s.com*/ */ public final List<TestResult> getResults() { LinkedList<TestResult> allresults = new LinkedList<TestResult>(); for (List<TestResult> r : results.values()) { allresults.addAll(r); } return allresults; }
From source file:org.apache.tajo.master.scheduler.SimpleScheduler.java
@Override public List<AllocationResourceProto> reserve(QueryId queryId, NodeResourceRequest request) { List<AllocationResourceProto> reservedResources; NodeResource capacity = new NodeResource(request.getCapacity()); if (!NodeResources.fitsIn(capacity, getClusterResource())) { return Lists.newArrayList(); }// www.j a va 2s .com LinkedList<Integer> workers = new LinkedList<>(); if (request.getCandidateNodesCount() > 0) { workers.addAll(request.getCandidateNodesList()); Collections.shuffle(workers); } int requiredContainers = request.getNumContainers(); // reserve resource from candidate workers for locality reservedResources = reserveClusterResource(workers, capacity, requiredContainers); // reserve resource in random workers if (reservedResources.size() < requiredContainers) { LinkedList<Integer> randomNodes = new LinkedList<>(getRMContext().getNodes().keySet()); Collections.shuffle(randomNodes); reservedResources.addAll( reserveClusterResource(randomNodes, capacity, requiredContainers - reservedResources.size())); } if (LOG.isDebugEnabled()) { LOG.debug("Request: " + request.getCapacity() + ", containerNum:" + request.getNumContainers() + "Current cluster resource: " + getClusterResource()); } return reservedResources; }
From source file:com.hp.alm.ali.idea.model.type.TeamType.java
@Override public FilterResolver getFilterResolver() { return new MultipleItemsResolver() { @Override//w w w .j a v a 2s.c o m public String toRESTQuery(String value) { List<String> values = new LinkedList<String>(Arrays.asList(value.split(";"))); LinkedList<String> ids = new LinkedList<String>(); if (values.remove(MultipleItemsTranslatedResolver.NO_VALUE)) { ids.add(MultipleItemsTranslatedResolver.NO_VALUE); } if (!values.isEmpty()) { EntityList teams = teamService.getMultipleTeams(values); ids.addAll(teams.getIdStrings()); } return StringUtils.join(ids, " OR "); } }; }
From source file:com.rathravane.drumlin.util.JsonBodyReader.java
/** * read the bytes for objects. If the bytes contain a single JSON object and the path is * not null, the objects are loaded from the value named by path rather than the top-level * object./* ww w.jav a2 s. co m*/ * * @param bytes * @param path * @return a list of 0 or more JSON objects * @throws IOException * @throws JSONException */ public static List<JSONObject> readBodyForObjects(final byte[] bytes, String path) throws IOException, JSONException { final LinkedList<JSONObject> result = new LinkedList<JSONObject>(); // determine the first token in the stream to decide if we're reading a single // object or an array. boolean isSingleObject = false; { final ByteArrayInputStream s = new ByteArrayInputStream(bytes); final JSONTokener t = new JSONTokener(s); char c = t.next(); while (Character.isWhitespace(c)) c = t.next(); switch (c) { case '{': isSingleObject = true; break; case '[': isSingleObject = false; break; default: throw new JSONException("Expected an object or an array of objects."); } s.close(); } if (isSingleObject) { final String jsonStream = new String(bytes, utf8); final JSONObject o = new JSONObject(jsonStream); if (path != null) { final Object oo = o.opt(path); if (oo instanceof JSONObject) { result.add((JSONObject) oo); } else if (oo instanceof JSONArray) { result.addAll(readArrayForObjects((JSONArray) oo)); } else { throw new JSONException("Couldn't read object at path [" + path + "]."); } } else { result.add(o); } } else { final String jsonStream = new String(bytes); final JSONArray a = new JSONArray(jsonStream); result.addAll(readArrayForObjects(a)); } return result; }
From source file:pl.edu.agh.iosr.lsf.dao.DatabaseHelper.java
public List<String[]> listTags() throws SQLException { try (Connection c = source.getConnection()) { LinkedList<String[]> r = new LinkedList<>(); PreparedStatement ps = c.prepareStatement(statementStore.get("LIST_TAGS")); ps.setInt(1, 1);/*w w w. j a v a 2 s. c o m*/ r.addAll(select(ps)); ps = c.prepareStatement(getStatement("LIST_TAGS")); ps.setInt(1, 0); r.addAll(select(ps)); return r; } }
From source file:pl.edu.agh.iosr.lsf.dao.DatabaseHelper.java
public List<String[]> listUsers() throws SQLException { try (Connection c = source.getConnection()) { LinkedList<String[]> r = new LinkedList<>(); PreparedStatement ps = c.prepareStatement(statementStore.get("LIST_USERS")); ps.setInt(1, 1);/* w ww. j a va 2 s . c o m*/ r.addAll(select(ps)); ps = c.prepareStatement(getStatement("LIST_USERS")); ps.setInt(1, 0); r.addAll(select(ps)); return r; } }
From source file:org.grails.datastore.mapping.simpledb.util.SimpleDBTemplateImpl.java
private List<Item> queryInternal(String query, int max, int attempt) { LinkedList<Item> items = new LinkedList<Item>(); try {// ww w . j a v a 2 s. c o m SelectRequest selectRequest = new SelectRequest(query); SelectResult result = sdb.select(selectRequest); items.addAll(result.getItems()); String nextToken = null; do { nextToken = result.getNextToken(); if (nextToken != null) { selectRequest = new SelectRequest(query).withNextToken(nextToken); result = sdb.select(selectRequest); items.addAll(result.getItems()); } } while (nextToken != null && items.size() < max); //truncate if needed while (items.size() > max) { items.removeLast(); } return items; } catch (AmazonServiceException e) { if (SimpleDBUtil.AWS_ERR_CODE_NO_SUCH_DOMAIN.equals(e.getErrorCode())) { throw new IllegalArgumentException("no such domain: " + query, e); } else if (SimpleDBUtil.AWS_ERR_CODE_SERVICE_UNAVAILABLE.equals(e.getErrorCode())) { //retry after a small pause SimpleDBUtil.sleepBeforeRetry(attempt); attempt++; return queryInternal(query, max, attempt); } else { throw e; } } }