List of usage examples for java.util ArrayList remove
public boolean remove(Object o)
From source file:net.sourceforge.mipa.predicatedetection.lattice.WindowedLatticeChecker.java
private void growLattice(LocalState localState, int id) { if (mappedLattice.size() == 0) { LocalState[] globalState = new LocalState[children.length]; String[] index = new String[children.length]; for (int i = 0; i < children.length; i++) { if (i != id) { globalState[i] = windowedLocalStateSet.get(i).get(windowedLocalStateSet.get(i).size() - 1); index[i] = globalState[i].getID(); }/*from w w w . ja v a2s. c o m*/ } globalState[id] = localState; index[id] = localState.getID(); AbstractLatticeIDNode node = createNode(globalState, index); ArrayList<String> setID = new ArrayList<String>(); ArrayList<AbstractLatticeIDNode> set = new ArrayList<AbstractLatticeIDNode>(); set.add(node); setID.add(StringUtils.join(index, ' ')); while (!set.isEmpty()) { AbstractLatticeIDNode newNode = set.remove(0); if (isCGS(newNode)) { set.clear(); setID.clear(); grow(newNode, id); break; } else { for (int i = 0; i < children.length; i++) { if (i == id) { continue; } index = new String[children.length]; globalState = new LocalState[children.length]; for (int j = 0; j < children.length; j++) { index[j] = newNode.getID()[j]; globalState[j] = newNode.getGlobalState()[j]; } index[i] = Integer.toString(Integer.valueOf(index[i]) - 1); if (!setID.contains(StringUtils.join(index, ' ')) && indexIsValid(index, id)) { globalState[i] = localStateSet.get(i).get(Integer.valueOf(index[i])); set.add(createNode(globalState, index)); setID.add(StringUtils.join(index, ' ')); } } } } } else { if (maxCGS.getGlobalState()[id] .equals(localStateSet.get(id).get(Integer.valueOf(localState.getID()) - 1))) { LocalState[] globalState = new LocalState[children.length]; String[] index = new String[children.length]; for (int i = 0; i < children.length; i++) { if (i != id) { globalState[i] = maxCGS.getGlobalState()[i]; index[i] = globalState[i].getID(); } } index[id] = localState.getID(); globalState[id] = localState; AbstractLatticeIDNode newNode = createNode(globalState, index); if (isCGS(newNode)) { grow(newNode, id); } } } }
From source file:gov.nih.nci.ispy.web.ajax.DynamicReportGenerator.java
public void generateDynamicReport(String key, Map<String, String> params, String stylesheet) { String html = new String(); HttpSession session = ExecutionContext.get().getSession(false); PresentationTierCache ptc = CacheFactory.getPresentationTierCache(); BusinessTierCache btc = CacheFactory.getBusinessTierCache(); HttpServletRequest request = ExecutionContext.get().getHttpServletRequest(); // HttpServletResponse response = ExecutionContext.get().getHttpServletResponse(); //lets hold a list of xml generating jobs, so we dont keep kicking off the same job ArrayList jobs = session.getAttribute("xmlJobs") != null ? (ArrayList) session.getAttribute("xmlJobs") : new ArrayList(); //only generate XML if its not already cached...leave off for debug //RCL - remove this constraint for now, to avoid caching for tasks with the same key/id //if(ptc.getPersistableObjectFromSessionCache(session.getId(), key) == null && !jobs.contains(key)) { Object o = btc.getObjectFromSessionCache(session.getId(), key); Finding finding = (Finding) o;//from w w w .j ava 2s . c om //generate the XML and cached it ReportGeneratorHelper.generateReportXML(finding); if (!jobs.contains(key)) jobs.add(key); session.setAttribute("xmlJobs", jobs); //} Object ob = ptc.getPersistableObjectFromSessionCache(session.getId(), key); if (ob != null && ob instanceof FindingReportBean) { try { FindingReportBean frb = (FindingReportBean) ob; Document reportXML = (Document) frb.getXmlDoc(); html = ReportGeneratorHelper.renderReport(params, reportXML, stylesheet); jobs.remove(key); session.setAttribute("xmlJobs", jobs); } catch (Exception e) { html = "Error Generating the report."; } } else { html = "Error generating the report"; } //out the XHTML in the session for reference in presentation...could store in Prescache session.setAttribute(key + "_xhtml", html); return; }
From source file:com.mdground.screen.activity.MainActivity.java
private void hideOpNO(int doctorID, int opNO) { Integer viewPagerIndex = doctorsIndex.get(String.valueOf(doctorID)); if (viewPagerIndex != null) { ((FlickerTextView) registeredViews.get(viewPagerIndex).findViewById(R.id.current_num)) .setVisibility(View.INVISIBLE); // ??,//ww w . j a v a 2s. c o m ArrayList<Appointment> appointments = allDoctorAppointmentArray.get(String.valueOf(doctorID)); if (appointments != null) { for (int i = 0; i < appointments.size(); i++) { Appointment item = appointments.get(i); if (item.getOPNo() == opNO) { appointments.remove(i); break; } } ((TwoWayGridView) registeredViews.get(viewPagerIndex).findViewById(R.id.gridview)) .setAdapter(new NumAdapter(appointments, doctorAdapter .getItemViewType(viewPagerIndex) == DoctorAdapter.DOCOTOR_ITEM_SINGLE)); } } }
From source file:edu.isi.wings.portal.controllers.PlanController.java
private ArrayList<TreeMap<String, Binding>> getParameterBindings(ArrayList<Template> cts) { ArrayList<TreeMap<String, Binding>> bindings_b = new ArrayList<TreeMap<String, Binding>>(); for (Template bt : cts) { TreeMap<String, Binding> binding_b = new TreeMap<String, Binding>(); for (Variable v : bt.getInputVariables()) { if (v.isParameterVariable() && v.getBinding() != null) { binding_b.put(v.getName(), v.getBinding()); }//from w w w . j av a 2 s.c o m } bindings_b.add(binding_b); } // Expanding collections into multiple configurations // FIXME: Cannot handle parameter collections right now ArrayList<TreeMap<String, Binding>> bindings = new ArrayList<TreeMap<String, Binding>>(); HashMap<String, Boolean> bstrs = new HashMap<String, Boolean>(); while (!bindings_b.isEmpty()) { boolean hasSets = false; TreeMap<String, Binding> binding_b = bindings_b.remove(0); TreeMap<String, Binding> binding = new TreeMap<String, Binding>(); for (String v : binding_b.keySet()) { Binding b = binding_b.get(v); if (b.isSet() && b.size() > 1) { for (WingsSet cb : b) { TreeMap<String, Binding> binding_x = new TreeMap<String, Binding>(); for (String v1 : binding_b.keySet()) { Binding b1 = binding_b.get(v1); binding_x.put(v1, b1); } binding_x.put(v, (Binding) cb); bindings_b.add(binding_x); } hasSets = true; } else if (b.isSet() && b.size() == 1) { Binding tmpb = (Binding) b.get(0); while (tmpb.isSet() && tmpb.size() == 1) { tmpb = (Binding) tmpb.get(0); } ValueBinding vb = (ValueBinding) tmpb; binding.put(v, new ValueBinding(vb.getValue(), vb.getDatatype())); } else if (!b.isSet()) { ValueBinding vb = (ValueBinding) b; binding.put(v, new ValueBinding(vb.getValue(), vb.getDatatype())); } } if (!hasSets) { String bstr = ""; for (String v : binding.keySet()) { bstr += binding.get(v).toString() + ","; } if (!bstrs.containsKey(bstr)) { bstrs.put(bstr, true); bindings.add(binding); } } } return bindings; }
From source file:com.mdground.screen.activity.MainActivity.java
private void showStartOpNO(int doctorID, int opNO) { Integer viewPagerIndex = doctorsIndex.get(String.valueOf(doctorID)); if (viewPagerIndex != null) { FlickerTextView textView = ((FlickerTextView) registeredViews.get(viewPagerIndex) .findViewById(R.id.current_num)); textView.setVisibility(View.VISIBLE); textView.setText(String.valueOf(opNO)); textView.stopFlicker();//from w w w . j ava 2 s .c o m // ??, ArrayList<Appointment> appointments = allDoctorAppointmentArray.get(String.valueOf(doctorID)); if (appointments != null) { for (int i = 0; i < appointments.size(); i++) { Appointment item = appointments.get(i); if (item.getOPNo() == opNO) { appointments.remove(i); break; } } ((TwoWayGridView) registeredViews.get(viewPagerIndex).findViewById(R.id.gridview)) .setAdapter(new NumAdapter(appointments, doctorAdapter .getItemViewType(viewPagerIndex) == DoctorAdapter.DOCOTOR_ITEM_SINGLE)); } } }
From source file:com.evolveum.midpoint.web.component.wizard.resource.SchemaHandlingStep.java
private void deleteObjectTypePerformed(AjaxRequestTarget target, ResourceObjectTypeDefinitionTypeDto objectType) { ResourceObjectTypeDefinitionType realObjectType = objectType.getObjectType(); resourceModel.getObject().asObjectable().getSchemaHandling().getObjectType().remove(realObjectType); if (isSelected(objectType)) { resetSelected();/* ww w.j av a 2 s. c o m*/ resetThirdRowContainer(target); } ArrayList<ResourceObjectTypeDefinitionTypeDto> list = (ArrayList<ResourceObjectTypeDefinitionTypeDto>) schemaHandlingDtoModel .getObject().getObjectTypeDtoList(); list.remove(objectType); if (list.isEmpty()) { resetThirdRowContainer(target); } target.add(getObjectTypeEditor(), getObjectListTable(), getNavigator()); parentPage.refreshIssues(target); }
From source file:de.fau.cs.osr.hddiff.HDDiff.java
private void removeLast(ArrayList<DiffNode> path) { path.remove(path.size() - 1); }
From source file:com.ngdata.hbaseindexer.indexer.FusionPipelineClient.java
protected synchronized Exception postJsonToPipelineWithRetry(String endpoint, List docs, ArrayList<String> mutable, Exception lastExc, int requestId) throws Exception { Exception retryAfterException = null; try {//from w w w. ja va 2 s. c om postJsonToPipeline(endpoint, docs, requestId); if (lastExc != null) log.info("Re-try request " + requestId + " to " + endpoint + " succeeded after seeing a " + lastExc.getMessage()); } catch (Exception exc) { log.warn("Failed to send request " + requestId + " to '" + endpoint + "' due to: " + exc); if (mutable.size() > 1) { // try another endpoint but update the cloned list to avoid re-hitting the one having an error if (log.isDebugEnabled()) log.debug("Will re-try failed request " + requestId + " on next endpoint in the list"); mutable.remove(endpoint); retryAfterException = exc; } else { // no other endpoints to try ... brief wait and then retry log.warn("No more endpoints available to try ... will retry to send request " + requestId + " to " + endpoint + " after waiting 1 sec"); try { Thread.sleep(1000); } catch (InterruptedException ignore) { Thread.interrupted(); } // note we want the exception to propagate from here up the stack since we re-tried and it didn't work postJsonToPipeline(endpoint, docs, requestId); log.info("Re-try request " + requestId + " to " + endpoint + " succeeded"); retryAfterException = null; // return success condition } } return retryAfterException; }
From source file:com.clematis.jsmodify.JSExecutionTracer.java
/** * This method sorts all four groups of trace objects into one ordered list of trace objects */// w ww .j a va 2 s . c om private static ArrayList<TraceObject> sortTraceObjects() { ArrayList<TraceObject> sortedTrace = new ArrayList<TraceObject>(); ArrayList<Collection<TraceObject>> allCollections = new ArrayList<Collection<TraceObject>>(); if (story.getDomEventTraces().size() > 0) { allCollections.add(story.getDomEventTraces()); } if (story.getFunctionTraces().size() > 0) { allCollections.add(story.getFunctionTraces()); } if (story.getTimingTraces().size() > 0) { allCollections.add(story.getTimingTraces()); } if (story.getXhrTraces().size() > 0) { allCollections.add(story.getXhrTraces()); } if (allCollections.size() == 0) { System.out.println("No log"); return null; } ArrayList<Integer> currentIndexInCollection = new ArrayList<Integer>(); for (int i = 0; i < allCollections.size(); i++) currentIndexInCollection.add(0); while (true) { int currentMinArray = 0; for (int i = 0; i < allCollections.size(); i++) { TraceObject traceObj = Iterables.get(allCollections.get(i), currentIndexInCollection.get(i)); TraceObject currObj = Iterables.get(allCollections.get(currentMinArray), currentIndexInCollection.get(currentMinArray)); if (traceObj.getCounter() < currObj.getCounter()) currentMinArray = i; } sortedTrace.add(Iterables.get(allCollections.get(currentMinArray), currentIndexInCollection.get(currentMinArray))); currentIndexInCollection.set(currentMinArray, currentIndexInCollection.get(currentMinArray) + 1); if (currentIndexInCollection.get(currentMinArray) >= allCollections.get(currentMinArray).size()) { allCollections.remove(currentMinArray); currentIndexInCollection.remove(currentMinArray); if (allCollections.size() == 0) break; } } return sortedTrace; }
From source file:edu.oregonstate.eecs.mcplan.domains.voyager.policies.KillPolicy.java
@Override public VoyagerAction getAction() { final ArrayList<Planet> friendly = Voyager.playerPlanets(s_, self_); final ArrayList<Planet> enemy = Voyager.playerPlanets(s_, self_.enemy()); if (enemy.isEmpty()) { return new NothingAction(); }/* w w w.ja va 2s . c o m*/ Planet target = null; double weight = 0; for (final Planet t : enemy) { final double tw = targetWeight(t, friendly); if (tw > weight) { weight = tw; target = t; } } if (target == null) { return new NothingAction(); } while (friendly.size() > 0) { Planet src = null; double dist = Double.MAX_VALUE; for (final Planet s : friendly) { final double sd = Voyager.distance(s, target); if (sd < dist) { dist = sd; src = s; } } if (src != null) { final int spare_soldiers = src.population(Unit.Soldier) - garrison_; if (spare_soldiers > 0) { final int[] pop = new int[Unit.values().length]; pop[Unit.Soldier.ordinal()] = spare_soldiers; return new LaunchAction(src, target, pop); } else { friendly.remove(src); } } } return new NothingAction(); }