List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:it.uniroma2.sag.kelp.data.representation.graph.DirectedGraphRepresentation.java
/** * Compute the distances between all pairs of nodes in the graph. * The results are stored into the field <code>nodesDistancesMap</code> (an hash map). * In order to access or modify the hash map use the methods <code>setNodeDistance()</code> * and <code>getNodeDistance()</code> *///from ww w . j ava 2s .c om private void computeNodeDistances() { this.nodesDistances = new ArrayList<NodeDistance>(0); int nnodes = this.getNumberOfNodes(); int[] tmpNodeDistances = new int[nnodes]; ArrayList<Integer> stack = new ArrayList<Integer>(); int j, arrayPosition, depth; for (int i = 0; i < nnodes; i++) { for (j = 0; j < nnodes; j++) { tmpNodeDistances[j] = Integer.MAX_VALUE; } stack.add(i); depth = 0; while (stack.size() > 0) { j = stack.remove(0); depth++; for (GraphNode v : this.nodes.get(j).getNeighbours()) { arrayPosition = this.nodesIdToGraphObjs.get(v.getId()); if (depth < tmpNodeDistances[arrayPosition]) { tmpNodeDistances[arrayPosition] = depth; stack.add(arrayPosition); //System.out.println("SP: adding pair (" + i + ", " + arrayPosition + ") -> " + depth); } } } for (j = 0; j < nnodes; j++) { depth = tmpNodeDistances[j]; if (depth < Integer.MAX_VALUE) { this.setNodesDistance(i, j, (float) tmpNodeDistances[j]); } } } Collections.sort(this.nodesDistances); }
From source file:hrpod.tools.nlp.StopWordRemoval.java
public ArrayList<String> removeStopWords(String[] words) { String newText = null;/*ww w .j a v a 2s. c o m*/ ArrayList<String> wordList = new ArrayList(); wordList.addAll(Arrays.asList(words)); //find stop/common words and remove them for (int w = 0; w < wordList.size(); w++) { String word = wordList.get(w); //break phrases down into individaul words ArrayList<String> subWordList = new ArrayList(); subWordList.addAll(Arrays.asList(wordList.get(w).split(" "))); //remove the stop words for (int swl = 0; swl < subWordList.size(); swl++) { for (int sw = 0; sw < stopWords.length; sw++) { String stopWord = stopWords[sw]; if (stopWords[sw].toLowerCase().contains(subWordList.get(swl).toLowerCase())) { //logger.info("REMOVE WORD: " + stopWords[sw]); subWordList.remove(swl); swl--; break; } } } wordList.set(w, StringUtils.join(subWordList, " ")); if (wordList.get(w).trim().equals("")) { wordList.remove(w); w--; } } //newText = StringUtils.join(wordList, " "); return wordList; }
From source file:com.kimbrelk.privileges.Privileges.java
/** * Will process (add and removed) privileges appropriately as based on the PrivilegeHolder's allowances and denials * @param privs An ArrayList of already allowed privileges * @param entity The PrivilegeHolder to process denials and allowances from *///from w w w . ja va2s .c o m private final void processPrivileges(ArrayList<String> privs, PrivilegeHolder entity) { if (entity == null || privs == null) return; // Denials ArrayList<String> denials = entity.getDenials(); for (String denial : denials) { if (denial.equals("*")) { privs.clear(); break; } privs.remove(denial); } // Allowances ArrayList<String> allowances = entity.getAllowances(); for (String allowance : allowances) { if (allowance.equals("*")) { ArrayList<String> t = getRegisteredPrivileges(); if (t != null) { privs.clear(); privs.addAll(t); return; } else { onError(ERROR_ALLOWANCE_WILDCARD_WITHOUT_KNOWN_PRIVS); } } else { privs.add(allowance); } } }
From source file:com.google.cloud.dns.testing.LocalDnsHelper.java
/** * Returns a list of four nameservers randomly chosen from the predefined set. *//*from ww w . ja v a2 s . c om*/ @VisibleForTesting static List<String> randomNameservers() { ArrayList<String> nameservers = Lists.newArrayList("dns1.googlecloud.com", "dns2.googlecloud.com", "dns3.googlecloud.com", "dns4.googlecloud.com", "dns5.googlecloud.com", "dns6.googlecloud.com"); while (nameservers.size() != 4) { int index = ID_GENERATOR.nextInt(nameservers.size()); nameservers.remove(index); } return nameservers; }
From source file:org.apache.usergrid.java.client.model.UsergridEntity.java
public void pop(@NotNull final String name) { ArrayList<Object> arrayToPop = this.getArrayToPopOrShift(name); if (arrayToPop != null && !arrayToPop.isEmpty()) { arrayToPop.remove(arrayToPop.size() - 1); this.putProperty(name, arrayToPop); }/*ww w. j av a 2s . co m*/ }
From source file:com.datos.vfs.provider.AbstractFileSystem.java
/** * Removes a listener from a file in this file system. * @param file The FileObject to be monitored. * @param listener The FileListener/* w ww . j a v a2s . c o m*/ */ @Override public void removeListener(final FileObject file, final FileListener listener) { synchronized (listenerMap) { final ArrayList<?> listeners = listenerMap.get(file.getName()); if (listeners != null) { listeners.remove(listener); if (listeners.isEmpty()) { listenerMap.remove(file.getName()); } } } }
From source file:org.apache.usergrid.java.client.model.UsergridEntity.java
public void shift(@NotNull final String name) { ArrayList<Object> arrayToShift = this.getArrayToPopOrShift(name); if (arrayToShift != null && !arrayToShift.isEmpty()) { arrayToShift.remove(0); this.putProperty(name, arrayToShift); }/*from w w w . j a va 2 s. c om*/ }
From source file:co.turnus.analysis.buffers.util.AbstractTraceCutScheduler.java
private BuffersData quickCutSchedule() { // start the progress monitor ProgressTheadPrinter pPrinter = new ProgressTheadPrinter( "Trace Graph post-processing, heuristic " + heuristic + ", iteration " + iteration, traceLength); pPrinter.start();//from w w w.j av a 2 s. c om ArrayList<Step> predictionWindow = new ArrayList<Step>(); // start the algorithm for (long id = 0; id < traceLength; id++) { Step step = trace.getStep(id); predictionWindow.add(step); if (predictionWindow.size() == maxSteps) { for (Step s : getNextSteps(predictionWindow)) { fire(s); predictionWindow.remove(s); pPrinter.increment(); } } } // fire the remaining steps while (firings < traceLength) { for (Step s : getNextSteps(predictionWindow)) { fire(s); predictionWindow.remove(s); pPrinter.increment(); } } TurnusLogger.debug("fired steps: " + firings + " of " + traceLength); // stop the progress monitor try { pPrinter.finish(); pPrinter.join(); } catch (InterruptedException e) { TurnusLogger.warning("Progress monitor stopping error: " + e.getMessage()); } if (firings > traceLength) { throw new TurnusRuntimeException("The number of firings is bigger then the trace size!"); } boolean deadlockFree = firings == traceLength; if (!deadlockFree) { TurnusLogger.warning("Infeasible configuration:" + "deadlock free not guaranteed!!"); } return collectResults(deadlockFree); }
From source file:com.redhat.rhn.manager.kickstart.cobbler.CobblerSystemCreateCommand.java
protected void processNetworkInterfaces(SystemRecord rec, Server serverIn) { List<Network> nics = new LinkedList<Network>(); if (serverIn.getNetworkInterfaces() != null) { for (NetworkInterface n : serverIn.getNetworkInterfaces()) { // don't create a physical network device for a bond if (n.isPublic() && !n.isVirtBridge() && !n.isBond()) { Network net = new Network(getCobblerConnection(), n.getName()); net.setIpAddress(n.getIpaddr()); net.setMacAddress(n.getHwaddr()); net.setNetmask(n.getNetmask()); if (!StringUtils.isBlank(networkInterface) && n.getName().equals(networkInterface)) { net.setStaticNetwork(!isDhcp); }/*ww w. ja v a2 s . co m*/ ArrayList<String> ipv6Addresses = n.getGlobalIpv6Addresses(); if (ipv6Addresses.size() > 0) { net.setIpv6Address(ipv6Addresses.get(0)); ipv6Addresses.remove(0); } if (ipv6Addresses.size() > 0) { net.setIpv6Secondaries(ipv6Addresses); } if (setupBridge && bridgeSlaves.contains(n.getName())) { net.makeBondingSlave(); net.setBondingMaster(bridgeName); } nics.add(net); } else if (setupBridge && bridgeSlaves.contains(n.getName())) { Network net = new Network(getCobblerConnection(), n.getName()); net.setMacAddress(n.getHwaddr()); net.makeBondingSlave(); net.setBondingMaster(bridgeName); nics.add(net); } } if (setupBridge) { Network net = new Network(getCobblerConnection(), bridgeName); net.makeBondingMaster(); net.setBondingOptions(bridgeOptions); net.setStaticNetwork(!isBridgeDhcp); if (!isBridgeDhcp) { net.setNetmask(bridgeNetmask); net.setIpAddress(bridgeAddress); rec.setGateway(bridgeGateway); } nics.add(net); } } rec.setNetworkInterfaces(nics); }
From source file:com.emental.mindraider.core.rest.resource.FolderResource.java
/** * Move notebook up in the folder./*from w ww .j ava 2s . c o m*/ * * @param notebookUri * the notebook uri * @return <code>true</code> if moved, else removed (should be placed into * the previous folder * @throws Exception * a generic exception */ @SuppressWarnings("unchecked") public boolean upNotebook(String notebookUri) throws Exception { if (notebookUri == null) { throw new MindRaiderException("Notebook URI can't be null!"); } // presuming that there exist exactly one notebooks group ResourcePropertyGroup[] notebooks = resource.getData() .getPropertyGroup(new URI(PROPERTY_GROUP_URI_NOTEBOOKS)); if (notebooks != null) { // search for the notebook URI ArrayList<NotebookProperty> arrProperties = notebooks[0].getProperties(); int i = 0; for (NotebookProperty notebookProperty : arrProperties) { if (notebookProperty.getUri().toASCIIString().equals(notebookUri)) { logger.debug(" Notebook found in properties..."); if (i > 0) { arrProperties.remove(i); arrProperties.add(i - 1, notebookProperty); notebooks[0].setProperties(arrProperties); return true; } // @todo inter folder moves of the folder not implemented logger.debug("DELEEEEEEEEEEEEETE!"); return false; } i++; } } else { throw new MindRaiderException("There is no property group!"); } return false; }