// ## operation writeChemkinSpecies(ReactionModel,SystemSnapshot) public static String writeChemkinSpecies( ReactionModel p_reactionModel, SystemSnapshot p_beginStatus) { // #[ operation writeChemkinSpecies(ReactionModel,SystemSnapshot) StringBuilder result = new StringBuilder(); result.append("SPECIES\n"); CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel; // write inert gas for (Iterator iter = p_beginStatus.getInertGas(); iter.hasNext(); ) { String name = (String) iter.next(); result.append('\t' + name + '\n'); } // write species for (Iterator iter = cerm.getSpecies(); iter.hasNext(); ) { Species spe = (Species) iter.next(); result.append('\t' + spe.getChemkinName() + '\n'); } result.append("END\n"); return result.toString(); // #] }
private Map promptForOverwrite(List plugins, List locales) { Map overwrites = new HashMap(); if (overwriteWithoutAsking) return overwrites; for (Iterator iter = plugins.iterator(); iter.hasNext(); ) { IPluginModelBase plugin = (IPluginModelBase) iter.next(); for (Iterator it = locales.iterator(); it.hasNext(); ) { Locale locale = (Locale) it.next(); IProject project = getNLProject(plugin, locale); if (project.exists() && !overwrites.containsKey(project.getName())) { boolean overwrite = MessageDialog.openConfirm( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteTitle, NLS.bind( PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteMessage, pluginName(plugin, locale))); overwrites.put(project.getName(), overwrite ? OVERWRITE : null); } } } return overwrites; }
public String buildInterfaceTable(String rule, String[] serviceList) throws FilterParseException { StringBuffer buffer = new StringBuffer(); Filter filter = new Filter(); Map interfaces = filter.getIPServiceMap(rule); Iterator i = interfaces.keySet().iterator(); while (i.hasNext()) { String key = (String) i.next(); buffer.append("<tr><td valign=\"top\">").append(key).append("</td>"); buffer.append("<td>"); if (serviceList != null && serviceList.length != 0) { Map services = (Map) interfaces.get(key); Iterator j = services.keySet().iterator(); while (j.hasNext()) { String svc = (String) j.next(); for (int idx = 0; idx < serviceList.length; idx++) { if (svc.equals(serviceList[idx])) { buffer.append(svc).append("<br>"); } } } } else { buffer.append("All services"); } buffer.append("</td>"); buffer.append("</tr>"); } return buffer.toString(); }
private int[] getHashes(LireFeature feature) { // result = new int[maximumHits]; hashingResultScoreDocs.clear(); maxDistance = 0f; tmpScore = 0f; int rep = 0; LireFeature tmpFeature; for (Iterator<LireFeature> iterator = representatives.iterator(); iterator.hasNext(); ) { tmpFeature = iterator.next(); tmpScore = tmpFeature.getDistance(feature); if (hashingResultScoreDocs.size() < maximumHits) { hashingResultScoreDocs.add(new SimpleResult(tmpScore, null, rep)); maxDistance = Math.max(maxDistance, tmpScore); } else if (tmpScore < maxDistance) { hashingResultScoreDocs.add(new SimpleResult(tmpScore, null, rep)); } while (hashingResultScoreDocs.size() > maximumHits) { hashingResultScoreDocs.remove(hashingResultScoreDocs.last()); maxDistance = hashingResultScoreDocs.last().getDistance(); } rep++; } rep = 0; for (Iterator<SimpleResult> iterator = hashingResultScoreDocs.iterator(); iterator.hasNext(); ) { SimpleResult next = iterator.next(); result[rep] = next.getIndexNumber(); rep++; } return result; }
public static void main(String[] args) throws FileNotFoundException { String s; ArrayList<String> AL = new ArrayList<String>(); AL.add("one"); AL.add("two"); AL.add("three"); AL.add("four"); AL.add("five"); AL.add("six"); System.out.println("ArrayList (iterator) " + AL); Iterator<String> it = AL.iterator(); while (it.hasNext()) { s = it.next(); System.out.println("AL: " + s); } System.out.println(); myList ml = new myList(); ml.add(20); ml.add(50); ml.add(12); ml.add(13); ml.add(53); ml.add(33); ml.add(23); System.out.println(ml); Iterator<Integer> mlit = ml.iterator(); while (mlit.hasNext()) { System.out.println(mlit.next()); } }
/** * Creates an NL fragment project along with the locale specific properties files. * * @throws CoreException * @throws IOException * @throws InvocationTargetException * @throws InterruptedException */ private void internationalizePlugins(List plugins, List locales, Map overwrites) throws CoreException, IOException, InvocationTargetException, InterruptedException { Set created = new HashSet(); for (Iterator it = plugins.iterator(); it.hasNext(); ) { IPluginModelBase plugin = (IPluginModelBase) it.next(); for (Iterator iter = locales.iterator(); iter.hasNext(); ) { Locale locale = (Locale) iter.next(); IProject project = getNLProject(plugin, locale); if (created.contains(project) || overwriteWithoutAsking || !project.exists() || OVERWRITE == overwrites.get(project.getName())) { if (!created.contains(project) && project.exists()) { project.delete(true, getProgressMonitor()); } if (!created.contains(project)) { createNLFragment(plugin, project, locale); created.add(project); project.getFolder(RESOURCE_FOLDER_PARENT).create(false, true, getProgressMonitor()); } project .getFolder(RESOURCE_FOLDER_PARENT) .getFolder(locale.toString()) .create(true, true, getProgressMonitor()); createLocaleSpecificPropertiesFile(project, plugin, locale); } } } }
public void testDescendingSubMapContents2() { ConcurrentNavigableMap map = dmap5(); SortedMap sm = map.subMap(m2, m3); assertEquals(1, sm.size()); assertEquals(m2, sm.firstKey()); assertEquals(m2, sm.lastKey()); assertFalse(sm.containsKey(m1)); assertTrue(sm.containsKey(m2)); assertFalse(sm.containsKey(m3)); assertFalse(sm.containsKey(m4)); assertFalse(sm.containsKey(m5)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer) (i.next()); assertEquals(m2, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(m2)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(m3), null); assertEquals(4, map.size()); }
/** * Determines whether {@code effect} has been paused/stopped by the remote peer. The determination * is based on counting frames and is triggered by the receipt of (a piece of) a new (video) frame * by {@code cause}. * * @param cause the {@code SimulcastLayer} which has received (a piece of) a new (video) frame and * has thus triggered a check on {@code effect} * @param pkt the {@code RawPacket} which was received by {@code cause} and possibly influenced * the decision to trigger a check on {@code effect} * @param effect the {@code SimulcastLayer} which is to be checked whether it looks like it has * been paused/stopped by the remote peer * @param endIndexInSimulcastLayerFrameHistory */ private void maybeTimeout( SimulcastLayer cause, RawPacket pkt, SimulcastLayer effect, int endIndexInSimulcastLayerFrameHistory) { Iterator<SimulcastLayer> it = simulcastLayerFrameHistory.iterator(); boolean timeout = true; for (int ix = 0; it.hasNext() && ix < endIndexInSimulcastLayerFrameHistory; ++ix) { if (it.next() == effect) { timeout = false; break; } } if (timeout) { effect.maybeTimeout(pkt); if (!effect.isStreaming()) { // Since effect has been determined to have been paused/stopped // by the remote peer, its possible presence in // simulcastLayerFrameHistory is irrelevant now. In other words, // remove effect from simulcastLayerFrameHistory. while (it.hasNext()) { if (it.next() == effect) it.remove(); } } } }
public ActionDescriptor getAction(int id) { // check global actions for (Iterator iterator = globalActions.iterator(); iterator.hasNext(); ) { ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next(); if (actionDescriptor.getId() == id) { return actionDescriptor; } } // check steps for (Iterator iterator = steps.iterator(); iterator.hasNext(); ) { StepDescriptor stepDescriptor = (StepDescriptor) iterator.next(); ActionDescriptor actionDescriptor = stepDescriptor.getAction(id); if (actionDescriptor != null) { return actionDescriptor; } } // check initial actions, which we now must have unique id's for (Iterator iterator = initialActions.iterator(); iterator.hasNext(); ) { ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next(); if (actionDescriptor.getId() == id) { return actionDescriptor; } } return null; }
/** * Put the JAIN-SIP stack in a state where it cannot receive any data and frees the network ports * used. That is to say remove JAIN-SIP <tt>ListeningPoint</tt>s and <tt>SipProvider</tt>s. */ @SuppressWarnings("unchecked") // jain-sip legacy code private void stopListening() { try { this.secureJainSipProvider.removeSipListener(this); this.stack.deleteSipProvider(this.secureJainSipProvider); this.secureJainSipProvider = null; this.clearJainSipProvider.removeSipListener(this); this.stack.deleteSipProvider(this.clearJainSipProvider); this.clearJainSipProvider = null; Iterator<ListeningPoint> it = this.stack.getListeningPoints(); Vector<ListeningPoint> lpointsToRemove = new Vector<ListeningPoint>(); while (it.hasNext()) { lpointsToRemove.add(it.next()); } it = lpointsToRemove.iterator(); while (it.hasNext()) { this.stack.deleteListeningPoint(it.next()); } this.stack.stop(); if (logger.isTraceEnabled()) logger.trace("stopped listening"); } catch (ObjectInUseException ex) { logger.fatal("Failed to stop listening", ex); } }
public static boolean HTTPRequestToFile( File file, String inUrl, String method, String data, List headers) { boolean success = false; try { if (file.exists()) file.delete(); } catch (Exception e) { Logger.getLogger(com.bombdiggity.util.HTTPUtils.class) .error( (new StringBuilder("HTTPUtils.HTTPRequestToFile delete (")) .append(file) .append("): ") .append(e.toString()) .toString()); } try { DataOutputStream printout = null; DataInputStream input = null; URL url = new URL(inUrl); URLConnection urlConn = url.openConnection(); urlConn.setDoInput(true); urlConn.setDoOutput(true); urlConn.setUseCaches(false); if (headers != null) { for (Iterator iter = headers.iterator(); iter.hasNext(); ) { Map nameValuePair = (Map) iter.next(); String key; String value; for (Iterator iter2 = nameValuePair.keySet().iterator(); iter2.hasNext(); urlConn.setRequestProperty(key, value)) { key = (String) iter2.next(); value = (String) nameValuePair.get(key); } } } if (data != null) { byte inData[] = data.getBytes("UTF-8"); printout = new DataOutputStream(urlConn.getOutputStream()); printout.write(inData); printout.flush(); printout.close(); printout = null; } input = new DataInputStream(urlConn.getInputStream()); DataOutputStream dataOut = new DataOutputStream(new FileOutputStream(file, false)); int rChunk = 0x10000; byte myData[] = new byte[rChunk]; do { int bytesRead = input.read(myData, 0, rChunk); if (bytesRead == -1) break; dataOut.write(myData, 0, bytesRead); Thread.sleep(1L); } while (true); input.close(); input = null; success = true; } catch (Exception exception) { } return success; }
/** * Inserts multiple mappings into the replica catalog. The input is a map indexed by the LFN. The * value for each LFN key is a collection of replica catalog entries. Note that this operation * will replace existing entries. * * @param x is a map from logical directory string to list of replica catalog entries. * @return the number of insertions. * @see edu.isi.pegasus.planner.catalog.replica.ReplicaCatalogEntry */ public int insert(Map x) { int result = 0; // shortcut sanity if (x == null || x.size() == 0) { return result; } for (Iterator i = x.keySet().iterator(); i.hasNext(); ) { String lfn = (String) i.next(); Object val = x.get(lfn); if (val instanceof ReplicaCatalogEntry) { // permit misconfigured clients result += insert(lfn, (ReplicaCatalogEntry) val); } else { // this is how it should have been for (Iterator j = ((Collection) val).iterator(); j.hasNext(); ) { ReplicaCatalogEntry rce = (ReplicaCatalogEntry) j.next(); result += insert(lfn, rce); } } } return result; }
/** * Retrieves multiple entries for a given logical directory, up to the complete catalog. * Retrieving full catalogs should be harmful, but may be helpful in online display or portal. * * <p> * * @param lfns is a set of logical directory strings to look up. * @param handle is the resource handle, restricting the LFNs. * @return a map indexed by the LFN. Each value is a set of physical filenames. */ public Map lookupNoAttributes(Set lfns, String handle) { Map result = new HashMap(); if (lfns == null || lfns.size() == 0) { return result; } for (Iterator i = lfns.iterator(); i.hasNext(); ) { String lfn = (String) i.next(); Collection c = (Collection) mLFNMap.get(lfn); if (c != null) { List value = new ArrayList(); for (Iterator j = c.iterator(); j.hasNext(); ) { ReplicaCatalogEntry rce = (ReplicaCatalogEntry) j.next(); String pool = rce.getResourceHandle(); if (pool == null && handle == null || pool != null && handle != null && pool.equals(handle)) { value.add(rce.getPFN()); } } // only put found LFNs into result result.put(lfn, value); } } // done return result; }
public void createBCode(CodeGeneration gen) { super.createBCode(gen); if (hasResult()) { TypeDecl type = null; BodyDecl b = enclosingBodyDecl(); if (b instanceof MethodDecl) { type = ((MethodDecl) b).type(); } else { throw new Error("Can not create code that returns value within non method"); } getResult().createBCode(gen); getResult().type().emitCastTo(gen, type); if (!finallyList().isEmpty()) { type.emitStoreLocal(gen, resultSaveLocalNum()); } for (Iterator iter = finallyList().iterator(); iter.hasNext(); ) { FinallyHost stmt = (FinallyHost) iter.next(); gen.emitJsr(stmt.label_finally_block()); } if (!finallyList().isEmpty()) { type.emitLoadLocal(gen, resultSaveLocalNum()); } type.emitReturn(gen); } else { for (Iterator iter = finallyList().iterator(); iter.hasNext(); ) { FinallyHost stmt = (FinallyHost) iter.next(); gen.emitJsr(stmt.label_finally_block()); } gen.emitReturn(); } }
private void deploy() { List startList = new ArrayList(); Iterator iter = dirMap.entrySet().iterator(); try { while (iter.hasNext() && !shutdown) { Map.Entry entry = (Map.Entry) iter.next(); File f = (File) entry.getKey(); QEntry qentry = (QEntry) entry.getValue(); long deployed = qentry.getDeployed(); if (deployed == 0) { if (deploy(f)) { if (qentry.isQBean()) startList.add(qentry.getInstance()); qentry.setDeployed(f.lastModified()); } else { // deploy failed, clean up. iter.remove(); } } else if (deployed != f.lastModified()) { undeploy(f); iter.remove(); loader.forceNewClassLoaderOnNextScan(); } } iter = startList.iterator(); while (iter.hasNext()) { start((ObjectInstance) iter.next()); } } catch (Exception e) { log.error("deploy", e); } }
static void writeDoc1(Document doc, PrintStream out) throws IOException { Vector<Annotation> entities = doc.annotationsOfType("entity"); if (entities == null) { System.err.println("No Entity: " + doc); return; } Iterator<Annotation> entityIt = entities.iterator(); int i = 0; while (entityIt.hasNext()) { Annotation entity = entityIt.next(); Vector mentions = (Vector) entity.get("mentions"); Iterator mentionIt = mentions.iterator(); String nameType = (String) entity.get("nameType"); while (mentionIt.hasNext()) { Annotation mention1 = (Annotation) mentionIt.next(); Annotation mention2 = new Annotation("refobj", mention1.span(), new FeatureSet()); mention2.put("objid", Integer.toString(i)); if (nameType != null) { mention2.put("netype", nameType); } doc.addAnnotation(mention2); } i++; } // remove other annotations. String[] annotypes = doc.getAnnotationTypes(); for (i = 0; i < annotypes.length; i++) { String t = annotypes[i]; if (!(t.equals("tagger") || t.equals("refobj") || t.equals("ENAMEX"))) { doc.removeAnnotationsOfType(t); } } writeDocRaw(doc, out); return; }
public static String writeChemkinPdepReactions(ReactionSystem rs) { // #[ operation writeChemkinReactions(ReactionModel) StringBuilder result = new StringBuilder(); result.append("REACTIONS KCAL/MOLE\n"); LinkedList rList = new LinkedList(); LinkedList troeList = new LinkedList(); LinkedList tbrList = new LinkedList(); LinkedList duplicates = new LinkedList(); LinkedList lindeList = new LinkedList(); if (rs.dynamicSimulator instanceof JDASPK) { rList = ((JDASPK) rs.dynamicSimulator).rList; troeList = ((JDASPK) rs.dynamicSimulator).troeList; tbrList = ((JDASPK) rs.dynamicSimulator).thirdBodyList; duplicates = ((JDASPK) rs.dynamicSimulator).duplicates; lindeList = ((JDASPK) rs.dynamicSimulator).lindemannList; } else if (rs.dynamicSimulator instanceof JDASSL) { rList = ((JDASSL) rs.dynamicSimulator).rList; troeList = ((JDASSL) rs.dynamicSimulator).troeList; tbrList = ((JDASSL) rs.dynamicSimulator).thirdBodyList; duplicates = ((JDASSL) rs.dynamicSimulator).duplicates; lindeList = ((JDASSL) rs.dynamicSimulator).lindemannList; } for (Iterator iter = rList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction) iter.next(); // 10/26/07 gmagoon: changed to avoid use of Global.temperature; I am using // getPresentTemperature for the time being; it is possible that // getInitialStatus.getTemperature or something similar may be more appropriate result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n"); // result.append(r.toChemkinString(Global.temperature)+"\n"); } for (Iterator iter = troeList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction) iter.next(); result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n"); // result.append(r.toChemkinString(Global.temperature)+"\n"); } for (Iterator iter = tbrList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction) iter.next(); result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n"); // result.append(r.toChemkinString(Global.temperature)+"\n"); } for (Iterator iter = duplicates.iterator(); iter.hasNext(); ) { Reaction r = (Reaction) iter.next(); result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n\tDUP\n"); // result.append(r.toChemkinString(Global.temperature)+"\n\tDUP\n"); } for (Iterator iter = lindeList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction) iter.next(); result.append(r.toChemkinString(rs.getPresentTemperature()) + "\n"); } result.append("END\n"); return result.toString(); // #] }
private void loadTerminologyFromXML(String filename) throws Exception { SAXBuilder builder = new SAXBuilder(); InputStream input = this.getClass().getResourceAsStream(filename); try { Document doc = builder.build(input); Element root = doc.getRootElement(); List codesets = root.getChildren("codeset"); codeSetList.clear(); groupList.clear(); for (Iterator it = codesets.iterator(); it.hasNext(); ) { Element element = (Element) it.next(); codeSetList.add(loadCodeSet(element)); } List groups = root.getChildren("group"); for (Iterator it = groups.iterator(); it.hasNext(); ) { Element element = (Element) it.next(); groupList.add(loadGroup(element)); } } finally { if (input != null) { input.close(); } } }
/** * Remove an action from this workflow completely. * * <p>This method will check global actions and all steps. * * @return true if the action was successfully removed, false if it was not found */ public boolean removeAction(ActionDescriptor actionToRemove) { // global actions for (Iterator iterator = getGlobalActions().iterator(); iterator.hasNext(); ) { ActionDescriptor actionDescriptor = (ActionDescriptor) iterator.next(); if (actionDescriptor.getId() == actionToRemove.getId()) { getGlobalActions().remove(actionDescriptor); return true; } } // steps for (Iterator iterator = getSteps().iterator(); iterator.hasNext(); ) { StepDescriptor stepDescriptor = (StepDescriptor) iterator.next(); ActionDescriptor actionDescriptor = stepDescriptor.getAction(actionToRemove.getId()); if (actionDescriptor != null) { stepDescriptor.getActions().remove(actionDescriptor); return true; } } return false; }
public void selectNext() { Iterator i = new SelectionIterator(this); if (m_actives.size() == 1) { boolean isFound = false; // loop the iterator in reverse order of drawing while (i.hasNext()) { GlyphObject object = (GlyphObject) i.next(); if (m_actives.isSelected(object)) { isFound = true; continue; } // if if (!isFound) { continue; } // if m_actives.unselectAll(); m_actives.addActive(object); return; } // while i } // if i = new SelectionIterator(this); if (i.hasNext()) { GlyphObject object = (GlyphObject) i.next(); m_actives.unselectAll(); m_actives.addActive(object); return; } // if }
private void stepTimeout() { boolean updated = false; synchronized (channels) { Iterator<ChannelInfo> it = channels.values().iterator(); while (it.hasNext()) { ChannelInfo channel = it.next(); Iterator<UserInfo> removed = channel.stepTimeout(getTimeoutLimit()); if (removed != null) { updated = true; String channelName = channel.getChannelName(); while (removed.hasNext()) { UserInfo user = removed.next(); ServerLogger.getInstance() .channelLeaved(channelName, user.getUserName(), user.getInetSocketAddress()); } if (channel.isEmpty()) { it.remove(); ServerLogger.getInstance().channelRemoved(channelName); } } } if (updated) { updateChannelsCache(); } } }
public void testIteration() { assertTrue(_nbhm.isEmpty()); assertThat(_nbhm.put("k1", "v1"), nullValue()); assertThat(_nbhm.put("k2", "v2"), nullValue()); String str1 = ""; for (Iterator<Map.Entry<String, String>> i = _nbhm.entrySet().iterator(); i.hasNext(); ) { Map.Entry<String, String> e = i.next(); str1 += e.getKey(); } assertThat("found all entries", str1, anyOf(is("k1k2"), is("k2k1"))); String str2 = ""; for (Iterator<String> i = _nbhm.keySet().iterator(); i.hasNext(); ) { String key = i.next(); str2 += key; } assertThat("found all keys", str2, anyOf(is("k1k2"), is("k2k1"))); String str3 = ""; for (Iterator<String> i = _nbhm.values().iterator(); i.hasNext(); ) { String val = i.next(); str3 += val; } assertThat("found all vals", str3, anyOf(is("v1v2"), is("v2v1"))); assertThat( "toString works", _nbhm.toString(), anyOf(is("{k1=v1, k2=v2}"), is("{k2=v2, k1=v1}"))); }
public WebProgram createWebProgram(List asps, JavaProgram jp) throws Exception { WebProgram wp = new WebProgram(asps, jp); for (Iterator itr = asps.iterator(); itr.hasNext(); ) { ASP asp = (ASP) itr.next(); asp.translate(); } // do the WebForm initialisation code List javaWebForms = wp.getWebForms(); Library library = jp.getLibrary(); for (Iterator itr = javaWebForms.iterator(); itr.hasNext(); ) { JavaClass jc = (JavaClass) itr.next(); WebTranslator.addJavaComponentInitialisation(jc, library); doExposePageLoadMethod(jc); } // do event hookups List hookups = jp.getEventHookupClasses(); for (Iterator itr = hookups.iterator(); itr.hasNext(); ) { EventSupport es = (EventSupport) itr.next(); // System.out.println(es.getVBSender()); for (Iterator itrr = asps.iterator(); itrr.hasNext(); ) { ASP asp = (ASP) itrr.next(); DNVariable v = asp.getComponent(es.getVBSender().getName()); if (v != null) { asp.addActionListenerFor(v, es.getName()); } } } return wp; }
// look up and apply coarts for given rels to each sign in result private void applyCoarts(List<String> coartRels, Collection<Sign> result) { List<Sign> inputSigns = new ArrayList<Sign>(result); result.clear(); List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size()); // for each rel, lookup coarts and apply to input signs, storing results in output signs for (Iterator<String> it = coartRels.iterator(); it.hasNext(); ) { String rel = it.next(); Collection<String> preds = (Collection<String>) _coartRelsToPreds.get(rel); if (preds == null) continue; // not expected Collection<Sign> coartResult = getSignsFromRelAndPreds(rel, preds); if (coartResult == null) continue; for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) { Sign coartSign = it2.next(); // apply to each input for (int j = 0; j < inputSigns.size(); j++) { Sign sign = inputSigns.get(j); grammar.rules.applyCoart(sign, coartSign, outputSigns); } } // switch output to input for next iteration inputSigns.clear(); inputSigns.addAll(outputSigns); outputSigns.clear(); } // add results back result.addAll(inputSigns); }
public void testSubMapContents2() { ConcurrentNavigableMap map = map5(); SortedMap sm = map.subMap(two, three); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer) (i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
private static LinkedHashMap sortHashMapByValuesD(HashMap passedMap) { List mapKeys = new ArrayList(passedMap.keySet()); List mapValues = new ArrayList(passedMap.values()); Collections.sort(mapValues); Collections.sort(mapKeys); LinkedHashMap sortedMap = new LinkedHashMap(); Iterator valueIt = mapValues.iterator(); while (valueIt.hasNext()) { Object val = valueIt.next(); Iterator keyIt = mapKeys.iterator(); while (keyIt.hasNext()) { Object key = keyIt.next(); String comp1 = passedMap.get(key).toString(); String comp2 = val.toString(); if (comp1.equals(comp2)) { passedMap.remove(key); mapKeys.remove(key); sortedMap.put(key, val); break; } } } return sortedMap; }
public void evaluation(String[] args) throws IOException { String devPath = args[0]; String hmmTransPath = args[1]; String hmmEmitPath = args[2]; String hmmPriorPath = args[3]; // alpha al = new alpha(); loadParameter(hmmTransPath, hmmEmitPath, hmmPriorPath); File devf = new File(devPath); FileReader devFr = new FileReader(devf); BufferedReader devBr = new BufferedReader(devFr); String line; while ((line = devBr.readLine()) != null) { double likelihood1 = 0; String[] observations = line.split(" "); Iterator<String> it = prior.keySet().iterator(); String state = it.next(); alphaRecord = new HashMap<Integer, HashMap<String, Double>>(); // sum all state likelihood1 = getAlpha(state, observations.length, line); // System.out.println(getAlpha(state, 1 , line)); while (it.hasNext()) { state = it.next(); double likelihood2 = getAlpha(state, observations.length, line); likelihood1 = Util.logSum(likelihood1, likelihood2); } System.out.println(likelihood1); } devBr.close(); }
void writeFiles(Vector allConfigs) { Hashtable allFiles = computeAttributedFiles(allConfigs); Vector allConfigNames = new Vector(); for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { allConfigNames.add(((BuildConfig) i.next()).get("Name")); } TreeSet sortedFiles = sortFiles(allFiles); startTag("Files", null); for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) { doWriteFiles(sortedFiles, allConfigNames, (NameFilter) i.next()); } startTag( "Filter", new String[] { "Name", "Resource Files", "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" }); endTag("Filter"); endTag("Files"); }
static void itTest4(Map s, int size, int pos) { IdentityHashMap seen = new IdentityHashMap(size); reallyAssert(s.size() == size); int sum = 0; timer.start("Iter XEntry ", size); Iterator it = s.entrySet().iterator(); Object k = null; Object v = null; for (int i = 0; i < size - pos; ++i) { Map.Entry x = (Map.Entry) (it.next()); k = x.getKey(); v = x.getValue(); seen.put(k, k); if (x != MISSING) ++sum; } reallyAssert(s.containsKey(k)); it.remove(); reallyAssert(!s.containsKey(k)); while (it.hasNext()) { Map.Entry x = (Map.Entry) (it.next()); Object k2 = x.getKey(); seen.put(k2, k2); if (x != MISSING) ++sum; } reallyAssert(s.size() == size - 1); s.put(k, v); reallyAssert(seen.size() == size); timer.finish(); reallyAssert(sum == size); reallyAssert(s.size() == size); }
/** * Method use OpenCsv Library for * * @param fileInputCsv the File CSV to parse. * @param separator the char separator. * @return the List of Bean parsed from the CSV file. */ public static List<String[]> parseCSVFileAsList(File fileInputCsv, char separator) { try { List<String[]> records; // read all lines at once try ( // create CSVReader object CSVReader reader = new CSVReader(new FileReader(fileInputCsv), separator)) { // read all lines at once records = reader.readAll(); Iterator<String[]> iterator = records.iterator(); records.clear(); // skip header row iterator.next(); while (iterator.hasNext()) { String[] record = iterator.next(); records.add(record); } } return records; } catch (IOException e) { logger.error( "Can't parse the CSV file:" + fileInputCsv.getAbsolutePath() + " -> " + e.getMessage(), e); return new ArrayList<>(); } }