List of usage examples for java.util List remove
E remove(int index);
From source file:fr.cph.chicago.util.Util.java
/** * Remove from bus favorites//from ww w .j a v a 2 s . c o m * * @param busRouteId the bus route id * @param busStopId the bus stop id * @param bound the bus bound * @param view the view */ public static void removeFromBusFavorites(@NonNull final String busRouteId, @NonNull final String busStopId, @NonNull final String bound, @NonNull final View view) { final String id = busRouteId + "_" + busStopId + "_" + bound; final List<String> favorites = Preferences.getBusFavorites(view.getContext(), App.PREFERENCE_FAVORITES_BUS); favorites.remove(id); Preferences.saveBusFavorites(view.getContext(), App.PREFERENCE_FAVORITES_BUS, favorites); showSnackBar(view, R.string.message_remove_fav); }
From source file:at.ac.tuwien.dsg.quelle.cloudServicesModel.util.conversions.ConvertToJSON.java
public static String convertToJSON(MultiLevelRequirements multiLevelRequirements) { //traverse the tree to do the JSON properly List<JSONObject> jsontree = new ArrayList<JSONObject>(); List<MultiLevelRequirements> multiLevelRequirementsTree = new ArrayList<MultiLevelRequirements>(); JSONObject root = processMultiLevelRequirementsElement(multiLevelRequirements); jsontree.add(root);// w w w .j a va 2s . c o m multiLevelRequirementsTree.add(multiLevelRequirements); //traverse the tree in a DFS manner while (!multiLevelRequirementsTree.isEmpty()) { MultiLevelRequirements currentlyProcessed = multiLevelRequirementsTree.remove(0); JSONObject currentlyProcessedJSONObject = jsontree.remove(0); JSONArray childrenArray = new JSONArray(); //process children for (MultiLevelRequirements child : currentlyProcessed.getContainedElements()) { JSONObject childJSON = processMultiLevelRequirementsElement(child); childrenArray.add(childJSON); //next to process are children jsontree.add(childJSON); multiLevelRequirementsTree.add(child); } if (currentlyProcessedJSONObject.containsKey("children")) { JSONArray array = (JSONArray) currentlyProcessedJSONObject.get("children"); array.addAll(childrenArray); } else { currentlyProcessedJSONObject.put("children", childrenArray); } } return root.toJSONString(); }
From source file:com.github.stagirs.lingvo.build.Xml2Plain.java
private static List<Attr> fillAttributes(List<Attr> list, Matcher attrMatcher) { while (attrMatcher.find()) { String attr = attrMatcher.group(1).replace("-", "_"); if (Character.isDigit(attr.charAt(0))) { attr = "N" + attr; }// w w w . j a va 2s . c o m if (attr.toLowerCase().equals("ms_f")) { if (list.contains(Attr.femn)) { list.remove(Attr.femn); } if (list.contains(Attr.masc)) { list.remove(Attr.masc); } if (list.contains(Attr.neut)) { list.remove(Attr.neut); } if (list.contains(Attr.GNdr)) { list.remove(Attr.GNdr); } list.add(ms_f); continue; } Attr attrVal = Attr.valueOf(attr); if (attrVal == Attr.inan && list.contains(Attr.anim)) { continue; } if (attrVal == Attr.anim && list.contains(Attr.inan)) { list.remove(Attr.inan); } if (attrVal == Attr.femn || attrVal == Attr.masc || attrVal == Attr.neut || attrVal == Attr.GNdr) { if (list.contains(ms_f)) { continue; } } if (attrVal == Attr.loc1 || attrVal == Attr.loc2) { attrVal = Attr.loct; } if (attrVal == Attr.gent || attrVal == Attr.gen1 || attrVal == Attr.gen2) { if (list.get(0) == Attr.ADJS) { continue; } attrVal = Attr.gent; } if (attrVal == Attr.acc2) { attrVal = Attr.accs; } if (attrVal.getType() == Type.Other) { continue; } list.add(attrVal); } if (list.contains(Attr.Name) || list.contains(Attr.Surn) || list.contains(Attr.Patr)) { list.remove(Attr.inan); if (!list.contains(Attr.anim)) { list.add(Attr.anim); } } if (list.contains(Attr.VERB) && list.contains(Attr.Impe) && list.contains(Attr.neut)) { list.remove(Attr.neut); } return list; }
From source file:Main.java
public static List<Map<String, Object>> listToTree(List<Map<String, Object>> datas, String idField, String pIdField) {/*from w w w.j a v a 2 s . co m*/ if (datas != null && datas.size() != 0) { ArrayList rootDatas = new ArrayList(datas.size()); int length = datas.size(); Map data = null; for (int i = 0; i < length; ++i) { data = (Map) datas.get(i); if (data.get(pIdField) == null || data.get(pIdField).toString().trim().length() == 0) { rootDatas.add(data); datas.remove(i); --i; --length; } } iterativeData(datas, rootDatas, idField, pIdField); return rootDatas; } else { return datas; } }
From source file:com.vmware.admiral.compute.container.volume.VolumeUtil.java
private static List<Set<String>> mergeSets(List<Set<String>> list) { if (list.size() < 2) { return list; }/*from w w w . j a va2 s .c om*/ for (int i = 0; i < list.size() - 1; i++) { Set<String> current = list.get(i); Set<String> next = list.get(i + 1); if (!disjoint(current, next)) { list.remove(current); list.remove(next); current.addAll(next); list.add(current); list = mergeSets(list); break; } } return list; }
From source file:fr.cph.chicago.util.Util.java
public static void removeFromBikeFavorites(final int stationId, @NonNull final View view) { final List<String> favorites = Preferences.getBikeFavorites(view.getContext(), App.PREFERENCE_FAVORITES_BIKE); favorites.remove(Integer.toString(stationId)); Preferences.saveBikeFavorites(view.getContext(), App.PREFERENCE_FAVORITES_BIKE, favorites); showSnackBar(view, R.string.message_remove_fav); }
From source file:com.aurel.track.admin.customize.lists.importList.ImportListBL.java
/** * Load the list hierarchy from the database which will be updated * @param globalList/* ww w . j a v a 2 s .co m*/ * @return */ public static List<TListBean> loadHierarchy(TListBean globalList) { List<TListBean> list = new ArrayList<TListBean>(); List<TListBean> queue = new ArrayList<TListBean>(); if (ListBL.loadByPrimaryKey(globalList.getObjectID()) != null) { list.add(globalList); queue.add(globalList); do { List<TListBean> childList = ListBL.getChildLists(queue.get(0).getObjectID()); queue.remove(0); Iterator itr = childList.iterator(); while (itr.hasNext()) { TListBean tmpListBean = (TListBean) itr.next(); list.add(tmpListBean); queue.add(tmpListBean); } } while (queue.size() != 0); } return list; }
From source file:fr.cph.chicago.util.Util.java
/** * Remove train from favorites/*from w w w . ja v a 2s .c o m*/ * * @param stationId the station id * @param view the view */ public static void removeFromTrainFavorites(@NonNull final Integer stationId, @NonNull final View view) { final List<Integer> favorites = Preferences.getTrainFavorites(view.getContext(), App.PREFERENCE_FAVORITES_TRAIN); favorites.remove(stationId); Preferences.saveTrainFavorites(view.getContext(), App.PREFERENCE_FAVORITES_TRAIN, favorites); showSnackBar(view, R.string.message_remove_fav); }
From source file:net.fenyo.gnetwatch.GenericTools.java
/** * Removes the part of a graph that is covered by another graph. * Note that the second graph need not to be a subgraph of the first one. * @param addr g1 initial graph.//from w w w . j av a2s.c o m * @param addr g2 graph defining links to remove to the initial graph. * @return void. */ static public void substractGraph(java.util.List<Pair<VisualElement, VisualElement>> g1, java.util.List<Pair<VisualElement, VisualElement>> g2) { final java.util.List<Pair<VisualElement, VisualElement>> gtemp = new LinkedList<Pair<VisualElement, VisualElement>>( g1); for (final Pair<VisualElement, VisualElement> p : gtemp) if (g2.contains(p)) g1.remove(p); }
From source file:hk.newsRecommender.Classify.java
public static void genNaiveBayesModel(Configuration conf, int labelIndex, String trainFile, String trainSeqFile, boolean hasHeader) { CSVReader reader = null;/*from www. j a v a 2 s . co m*/ try { FileSystem fs = FileSystem.get(conf); if (fs.exists(new Path(trainSeqFile))) fs.delete(new Path(trainSeqFile), true); SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, new Path(trainSeqFile), Text.class, VectorWritable.class); FileSystem fsopen = FileSystem.get(conf); FSDataInputStream in = fsopen.open(new Path(trainFile)); reader = new CSVReader(new InputStreamReader(in)); String[] header = null; if (hasHeader) header = reader.readNext(); String[] line = null; Long l = 0L; while ((line = reader.readNext()) != null) { if (labelIndex > line.length) break; l++; List<String> tmpList = Lists.newArrayList(line); String label = tmpList.get(labelIndex); if (!strLabelList.contains(label)) strLabelList.add(label); // Text key = new Text("/" + label + "/" + l); Text key = new Text("/" + label + "/"); tmpList.remove(labelIndex); VectorWritable vectorWritable = new VectorWritable(); Vector vector = new RandomAccessSparseVector(tmpList.size(), tmpList.size());//??? for (int i = 0; i < tmpList.size(); i++) { String tmpStr = tmpList.get(i); if (StringUtils.isNumeric(tmpStr)) vector.set(i, Double.parseDouble(tmpStr)); else vector.set(i, parseStrCell(tmpStr)); } vectorWritable.set(vector); writer.append(key, vectorWritable); } writer.close(); } catch (IOException e) { e.printStackTrace(); } }