List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:Debug.java
public static boolean compare(String prefix, Map a, Map b, ArrayList ignore, StringBuffer buffer) { if ((a == null) && (b == null)) { log(buffer, prefix + " both maps null"); return true; }//from w w w .j a va 2 s . c om if (a == null) { log(buffer, prefix + " map a: null, map b: map"); return false; } if (b == null) { log(buffer, prefix + " map a: map, map b: null"); return false; } ArrayList keys_a = new ArrayList(a.keySet()); ArrayList keys_b = new ArrayList(b.keySet()); if (ignore != null) { keys_a.removeAll(ignore); keys_b.removeAll(ignore); } boolean result = true; for (int i = 0; i < keys_a.size(); i++) { Object key = keys_a.get(i); if (!keys_b.contains(key)) { log(buffer, prefix + "b is missing key '" + key + "' from a"); result = false; } else { keys_b.remove(key); Object value_a = a.get(key); Object value_b = b.get(key); if (!value_a.equals(value_b)) { log(buffer, prefix + "key(" + key + ") value a: " + value_a + ") != b: " + value_b + ")"); result = false; } } } for (int i = 0; i < keys_b.size(); i++) { Object key = keys_b.get(i); log(buffer, prefix + "a is missing key '" + key + "' from b"); result = false; } if (result) log(buffer, prefix + "a is the same as b"); return result; }
From source file:androidGLUESigner.helpers.SettingsHelper.java
/** * removes a file from the signed document list * @param path to the file//from w w w. j a va 2 s .co m */ public void removeSignedDocumentFromList(String path) { ArrayList<String> values = getSignedDocList(); values.remove(path); saveNewDocList(values, sharedPref.edit()); }
From source file:change_point_detection.BetaDistributionChangePoint.java
public void shrinkList(ArrayList<Double> list, int position /* inclusive */) { for (int index = 0; index <= position; index++) { list.remove(0); }/*ww w. j a va 2s .co m*/ }
From source file:com.github.gekoh.yagen.hibernate.PatchHibernateMappingClasses.java
public static Collection<String> splitSQL(String sql) { Matcher matcher = SEPARATOR_PATTERN.matcher(sql); int endIdx, idx = 0; ArrayList<String> statements = new ArrayList<String>(); while (matcher.find(idx)) { endIdx = matcher.start();//from w w w . ja va 2 s .co m if (endIdx - idx > 0) { statements.add(sql.substring(idx, endIdx)); } if (endIdx >= 0) { idx = matcher.end(); } } if (idx < sql.length()) { String singleSql = sql.substring(idx); if (StringUtils.isNotEmpty(singleSql.trim())) { statements.add(singleSql); } } for (int i = 0; i < statements.size(); i++) { String stmt = statements.get(i); if (stmt == null || stmt.trim().length() < 1) { statements.remove(i); i--; continue; } matcher = COMMENT_PATTERN.matcher(stmt); if (matcher.find() && stmt.substring(0, matcher.start()).trim().length() < 1) { statements.remove(i); statements.add(i, stmt.substring(matcher.end())); if (stmt.substring(0, matcher.end()).trim().length() > 0) { statements.add(i, stmt.substring(0, matcher.end())); } } } return statements; }
From source file:com.gabrielluz.megasenaanalyzer.MegaSenaAnalyzer.java
public void openLotteryHtml() throws DataFormatException { try {// www . ja v a2 s. c om String resultsUrl = "http://www1.caixa.gov.br/loterias/_arquivos/loterias/D_megase.zip"; HtmlTableParser tableParser = new HtmlTableParser(); String strTableFile = new String(MegaSenaAnalyzer.downloadFile(resultsUrl), Charset.defaultCharset()); tableParser.parse(strTableFile); String[][] arrayTableFile = tableParser.getContentsArray(); //arrayTableFIle transformed to ArrayList finalArrayTable this._finalArrayTable = new ArrayList<>(); for (String[] str1 : arrayTableFile) { this._finalArrayTable.add(new ArrayList<>(Arrays.asList(str1))); } //Removing useless data for (int i = 0; i < this._finalArrayTable.size(); i++) { ArrayList<String> a = this._finalArrayTable.get(i); a.remove(10); //Remove city a.remove(10); //Remove state if (!NumberUtils.isNumber(a.get(0))) { this._finalArrayTable.remove(i); i--; } } System.out.println("_finalArrayTable = " + _finalArrayTable.size()); //Set all picked numbers this._pickedNumbers = new ArrayList<>(); ArrayList<Integer> tempArray; for (int i = 0; i < this._finalArrayTable.size(); i++) { tempArray = new ArrayList<>(); tempArray.add(Integer.parseInt(this._finalArrayTable.get(i).get(2))); tempArray.add(Integer.parseInt(this._finalArrayTable.get(i).get(3))); tempArray.add(Integer.parseInt(this._finalArrayTable.get(i).get(4))); tempArray.add(Integer.parseInt(this._finalArrayTable.get(i).get(5))); tempArray.add(Integer.parseInt(this._finalArrayTable.get(i).get(6))); tempArray.add(Integer.parseInt(this._finalArrayTable.get(i).get(7))); Collections.sort(tempArray); this._pickedNumbers.add(tempArray); } } catch (IOException ex) { Logger.getLogger(MegaSenaAnalyzer.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:css.variable.converter.CSSVariableConverter.java
private static void loadCSSFiles(File releaseDirectory) { CSSFilter theCSSFilter = new CSSFilter(); DirectoryFilter theDirectoryFilter = new DirectoryFilter(); ArrayList<String> theDirectoryList = new ArrayList<String>(); // We're about to go look for every CSS file in a sub directory theDirectoryList.add(releaseDirectory.getAbsolutePath());// Add the current directory while (!theDirectoryList.isEmpty()) { File currentDirectory = new File(theDirectoryList.get(0)); File[] currentCSSFiles = currentDirectory.listFiles(theCSSFilter); File[] subDirectories = currentDirectory.listFiles(theDirectoryFilter); // Add any css files found to theCSSList if (currentCSSFiles != null) { for (File cssFile : currentCSSFiles) { theCSSList.add(cssFile); }//from w w w . ja v a 2 s .c o m } // Add any more subdirectories found to the directory list. if (subDirectories != null) { for (File dir : subDirectories) { theDirectoryList.add(dir.getPath()); } } // Remove current directory. theDirectoryList.remove(0); } }
From source file:com.onpositive.semantic.words3.MultiHashMap.java
public Object removeObject(Object key, Object item) { ArrayList valuesForKey = (ArrayList) super.get(key); if (valuesForKey == null) return null; valuesForKey.remove(item); return item;/*from w w w . j a v a2s . c o m*/ }
From source file:io.ucoin.ucoinj.core.client.model.bma.gson.EndpointAdapter.java
@Override public NetworkPeering.Endpoint read(JsonReader reader) throws IOException { if (reader.peek() == com.google.gson.stream.JsonToken.NULL) { reader.nextNull();//from w ww . jav a 2 s . c o m return null; } String ept = reader.nextString(); ArrayList<String> parts = new ArrayList<>(Arrays.asList(ept.split(" "))); NetworkPeering.Endpoint endpoint = new NetworkPeering.Endpoint(); endpoint.port = Integer.parseInt(parts.remove(parts.size() - 1)); for (String word : parts) { if (InetAddressUtils.isIPv4Address(word)) { endpoint.ipv4 = word; } else if (InetAddressUtils.isIPv6Address(word)) { endpoint.ipv6 = word; } else if (word.startsWith("http")) { endpoint.url = word; } else { try { endpoint.protocol = EndpointProtocol.valueOf(word); } catch (IllegalArgumentException e) { // skip this part } } } if (endpoint.protocol == null) { endpoint.protocol = EndpointProtocol.UNDEFINED; } return endpoint; }
From source file:alpine.event.framework.BaseEventService.java
/** * {@inheritDoc}//from w w w . j a v a2 s. c o m * @since 1.0.0 */ public void unsubscribe(Class<? extends Subscriber> subscriberType) { for (ArrayList<Class<? extends Subscriber>> list : subscriptionMap.values()) { list.remove(subscriberType); } }
From source file:eu.cassandra.utils.Utils.java
/** * This function is used to remove the smallest points of interest from a list * in order to make its size viable to estimate the pairs. * //from ww w .j ava2 s . c om * @param pois * The list of points of interest. * @return The list of points of interest with a percentage of the points * removed. */ public static ArrayList<PointOfInterest> removePoints(ArrayList<PointOfInterest> pois) { ArrayList<PointOfInterest> result = new ArrayList<PointOfInterest>(); int number = pois.size() - Constants.REMOVAL_MAX_POINTS; log.debug("Initial Size: " + pois.size() + " Removing: " + number); Collections.sort(pois, Constants.comp4); log.debug("Initial POIS: " + pois.toString()); Collections.sort(result, Constants.comp4); for (int i = 0; i < number; i++) result.add(pois.remove(pois.size() - 1)); log.debug("Removed POIS: " + result.toString()); return result; }