List of usage examples for java.util LinkedHashMap containsKey
boolean containsKey(Object key);
From source file:com.espertech.esper.epl.join.plan.NStreamOuterQueryPlanBuilder.java
private static void addNotYetNavigated(int streamNo, int numStreams, LinkedHashMap<Integer, int[]> substreamsPerStream, NStreamQueryPlanBuilder.BestChainResult bestChain) { // sum up all substreams (the query plan for each stream: nested iteration or cardinal) Set<Integer> streams = new HashSet<Integer>(); streams.add(streamNo);/*from w w w. j a v a 2 s . co m*/ recursiveAdd(streamNo, streamNo, substreamsPerStream, streams, false); // we are done, all have navigated if (streams.size() == numStreams) { return; } int previous = streamNo; for (int stream : bestChain.getChain()) { if (streams.contains(stream)) { previous = stream; continue; } // add node as a nested join to the previous stream int[] substreams = substreamsPerStream.get(previous); if (substreams == null) { substreams = new int[0]; } int[] added = CollectionUtil.addValue(substreams, stream); substreamsPerStream.put(previous, added); if (!substreamsPerStream.containsKey(stream)) { substreamsPerStream.put(stream, new int[0]); } previous = stream; } }
From source file:com.github.shareme.gwschips.library.BaseRecipientAdapter.java
private static void putOneEntry(TemporaryEntry entry, boolean isAggregatedEntry, LinkedHashMap<Long, List<RecipientEntry>> entryMap, List<RecipientEntry> nonAggregatedEntries, Set<String> existingDestinations) { if (existingDestinations.contains(entry.destination)) { return;//w ww.ja v a2 s . c om } existingDestinations.add(entry.destination); if (!isAggregatedEntry) { nonAggregatedEntries .add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.directoryId, entry.dataId, entry.thumbnailUriString, true, entry.lookupKey)); } else if (entryMap.containsKey(entry.contactId)) { // We already have a section for the person. final List<RecipientEntry> entryList = entryMap.get(entry.contactId); entryList.add(RecipientEntry.constructSecondLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.directoryId, entry.dataId, entry.thumbnailUriString, true, entry.lookupKey)); } else { final List<RecipientEntry> entryList = new ArrayList<>(); entryList.add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.directoryId, entry.dataId, entry.thumbnailUriString, true, entry.lookupKey)); entryMap.put(entry.contactId, entryList); } }
From source file:org.openmeetings.cli.OmHelpFormatter.java
@SuppressWarnings("unchecked") private LinkedHashMap<String, List<OmOption>> getOptions(Options opts, int leftPad) { final String longOptSeparator = " "; final String lpad = createPadding(leftPad); final String lpadParam = createPadding(leftPad + 2); List<OmOption> reqOptions = getReqOptions(opts); LinkedHashMap<String, List<OmOption>> map = new LinkedHashMap<String, List<OmOption>>(reqOptions.size()); map.put(GENERAL_OPTION_GROUP, new ArrayList<OmOption>()); for (OmOption o : reqOptions) { map.put(o.getOpt(), new ArrayList<OmOption>()); }//from w w w .jav a 2 s . com for (OmOption o : (Collection<OmOption>) opts.getOptions()) { //TODO need better check (required option should go first and should not be duplicated boolean skipOption = map.containsKey(o.getOpt()); boolean mainOption = skipOption || o.getGroup() == null; // first create list containing only <lpad>-a,--aaa where // -a is opt and --aaa is long opt; in parallel look for // the longest opt string this list will be then used to // sort options ascending StringBuilder optBuf = new StringBuilder(); if (o.getOpt() == null) { optBuf.append(mainOption ? lpad : lpadParam).append(" ").append(getLongOptPrefix()) .append(o.getLongOpt()); } else { optBuf.append(mainOption ? lpad : lpadParam).append(getOptPrefix()).append(o.getOpt()); if (o.hasLongOpt()) { optBuf.append(',').append(getLongOptPrefix()).append(o.getLongOpt()); } } if (o.hasArg()) { String argName = o.getArgName(); if (argName != null && argName.length() == 0) { // if the option has a blank argname optBuf.append(' '); } else { optBuf.append(o.hasLongOpt() ? longOptSeparator : " "); optBuf.append("<").append(argName != null ? o.getArgName() : getArgName()).append(">"); } } o.setHelpPrefix(optBuf); maxPrefixLength = Math.max(optBuf.length(), maxPrefixLength); if (skipOption) { //TODO need better check (required option should go first and should not be duplicated continue; } String grp = o.getGroup(); grp = grp == null ? GENERAL_OPTION_GROUP : grp; String[] grps = grp.split(","); for (String g : grps) { map.get(g).add(o); } } for (String _key : map.keySet()) { final String key = _key; List<OmOption> options = map.get(key); Collections.sort(options, new Comparator<OmOption>() { public int compare(OmOption o1, OmOption o2) { boolean o1opt = !o1.isOptional(key); boolean o2opt = !o2.isOptional(key); return (o1opt && o2opt || !o1opt && !o2opt) ? (o1.getOpt() == null ? 1 : -1) : (o1opt ? -1 : 1); } }); if (opts.hasOption(key)) { options.add(0, (OmOption) opts.getOption(key)); } } return map; }
From source file:com.espertech.esper.regression.support.PatternTestHarness.java
private void checkResults(PatternTestStyle testStyle, String eventId) { // For each test descriptor, make sure the listener has received exactly the events expected int index = 0; log.debug(".checkResults Checking results for event " + eventId); for (EventExpressionCase descriptor : caseList.getResults()) { String expressionText = expressions[index].getText(); LinkedHashMap<String, LinkedList<EventDescriptor>> allExpectedResults = descriptor.getExpectedResults(); EventBean[] receivedResults = listeners[index].getLastNewData(); index++;//w w w . j a v a 2 s . c om // If nothing at all was expected for this event, make sure nothing was received if (!(allExpectedResults.containsKey(eventId))) { if ((receivedResults != null) && (receivedResults.length > 0)) { log.debug(".checkResults Incorrect result for style " + testStyle + " expression : " + expressionText); log.debug(".checkResults Expected no results for event " + eventId + ", but received " + receivedResults.length + " events"); log.debug(".checkResults Received, have " + receivedResults.length + " entries"); printList(receivedResults); TestCase.assertFalse(true); } continue; } LinkedList<EventDescriptor> expectedResults = allExpectedResults.get(eventId); // Compare the result lists, not caring about the order of the elements try { if (!(compareLists(receivedResults, expectedResults))) { log.debug(".checkResults Incorrect result for style " + testStyle + " expression : " + expressionText); log.debug(".checkResults Expected size=" + expectedResults.size() + " received size=" + (receivedResults == null ? 0 : receivedResults.length)); log.debug(".checkResults Expected, have " + expectedResults.size() + " entries"); printList(expectedResults); log.debug(".checkResults Received, have " + (receivedResults == null ? 0 : receivedResults.length) + " entries"); printList(receivedResults); TestCase.assertFalse(true); } } catch (Exception ex) { ex.printStackTrace(); Assert.fail("For statement '" + expressionText + "' failed to assert: " + ex.getMessage()); } } }
From source file:edu.asu.msse.dssoni.moviedescrpitionapp.JsonRPCClientViaThread.java
public void run() { // parent.myListAdapter.model.clear(); LinkedHashMap<String, List<String>> model = new LinkedHashMap<>(); try {//from w w w. ja v a2 s. c o m for (int i = 0; i < jo.length(); i++) { String title = jo.names().getString(i); String values = jo.getString((jo.names().getString(i))); JSONArray ja = new JSONArray(values); List<String> list = new ArrayList<>(ja.length()); for (int j = 0; j < ja.length(); j++) { list.add(ja.getString(j)); } if (!model.containsKey(title)) model.put(title, list); } parent.myListAdapter.model = model; parent.myListAdapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.opengamma.analytics.financial.interestrate.capletstripping.SABRTermStructureModelProvider.java
/** * General set up for a SABRTermStructureModelProvider * @param knotPoints Map between parameter curve names ("alpha", "beta", "rho" and "nu") and the positions of the knot points on each of those curves * @param interpolators Map between parameter curve names ("alpha", "beta", "rho" and "nu") and the interpolator used to describe that curve * @param parameterTransforms Map between parameter curve names ("alpha", "beta", "rho" and "nu") and the parameter transform used for that curve * @param knownParameterTermSturctures Map between known curve names (could be "alpha", "beta", "rho" and "nu") and the known curve(s) *//*from ww w. ja va 2 s .c o m*/ public SABRTermStructureModelProvider(LinkedHashMap<String, double[]> knotPoints, final LinkedHashMap<String, Interpolator1D> interpolators, final LinkedHashMap<String, ParameterLimitsTransform> parameterTransforms, final LinkedHashMap<String, InterpolatedDoublesCurve> knownParameterTermSturctures) { Validate.notNull(knotPoints, "null node points"); Validate.notNull(interpolators, "null interpolators"); Validate.isTrue(knotPoints.size() == interpolators.size(), "size mismatch between nodes and interpolators"); if (knownParameterTermSturctures == null) { Validate.isTrue(knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue(knotPoints.containsKey(BETA) && interpolators.containsKey(BETA), "beta curve not found"); Validate.isTrue(knotPoints.containsKey(NU) && interpolators.containsKey(NU), "nu curve not found"); Validate.isTrue(knotPoints.containsKey(RHO) && interpolators.containsKey(RHO), "rho curve not found"); } else { Validate.isTrue((knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA)) ^ knownParameterTermSturctures.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue((knotPoints.containsKey(BETA) && interpolators.containsKey(BETA)) ^ knownParameterTermSturctures.containsKey(BETA), "beta curve not found"); Validate.isTrue((knotPoints.containsKey(NU) && interpolators.containsKey(NU)) ^ knownParameterTermSturctures.containsKey(NU), "nu curve not found"); Validate.isTrue((knotPoints.containsKey(RHO) && interpolators.containsKey(RHO)) ^ knownParameterTermSturctures.containsKey(RHO), "rho curve not found"); } final LinkedHashMap<String, Interpolator1D> transInterpolators = new LinkedHashMap<>(); for (final Map.Entry<String, Interpolator1D> entry : interpolators.entrySet()) { final String name = entry.getKey(); final Interpolator1D temp = new TransformedInterpolator1D(entry.getValue(), parameterTransforms.get(name)); transInterpolators.put(name, temp); } _curveBuilder = new InterpolatedCurveBuildingFunction(knotPoints, transInterpolators); // _parameterTransforms = parameterTransforms; //TODO all the check for this _knownParameterTermStructures = knownParameterTermSturctures; }
From source file:ubic.gemma.persistence.service.expression.designElement.CompositeSequenceServiceImpl.java
/** * Checks to see if the CompositeSequence exists in any of the array designs. If so, it is internally stored in the * collection of composite sequences as a HashSet, preserving order based on insertion. *//*from w w w . jav a 2 s . c o m*/ @Override public Collection<CompositeSequence> findByNamesInArrayDesigns(Collection<String> compositeSequenceNames, Collection<ArrayDesign> arrayDesigns) { LinkedHashMap<String, CompositeSequence> compositeSequencesMap = new LinkedHashMap<>(); for (ArrayDesign arrayDesign : arrayDesigns) { for (Object obj : compositeSequenceNames) { String name = (String) obj; name = StringUtils.trim(name); AbstractService.log.debug("entered: " + name); CompositeSequence cs = this.findByName(arrayDesign, name); if (cs != null && !compositeSequencesMap.containsKey(cs.getName())) { compositeSequencesMap.put(cs.getName(), cs); } else { AbstractService.log.warn("Composite sequence " + name + " does not exist. Discarding ... "); } } } if (compositeSequencesMap.isEmpty()) return null; return compositeSequencesMap.values(); }
From source file:org.apache.openmeetings.cli.OmHelpFormatter.java
private LinkedHashMap<String, List<OmOption>> getOptions(Options opts, int leftPad) { final String longOptSeparator = " "; final String lpad = createPadding(leftPad); final String lpadParam = createPadding(leftPad + 2); List<OmOption> reqOptions = getReqOptions(opts); LinkedHashMap<String, List<OmOption>> map = new LinkedHashMap<String, List<OmOption>>(reqOptions.size()); map.put(GENERAL_OPTION_GROUP, new ArrayList<OmOption>()); for (OmOption o : reqOptions) { map.put(o.getOpt(), new ArrayList<OmOption>()); }//from www . ja va 2 s . c o m for (Option _o : opts.getOptions()) { OmOption o = (OmOption) _o; //TODO need better check (required option should go first and should not be duplicated boolean skipOption = map.containsKey(o.getOpt()); boolean mainOption = skipOption || o.getGroup() == null; // first create list containing only <lpad>-a,--aaa where // -a is opt and --aaa is long opt; in parallel look for // the longest opt string this list will be then used to // sort options ascending StringBuilder optBuf = new StringBuilder(); if (o.getOpt() == null) { optBuf.append(mainOption ? lpad : lpadParam).append(" ").append(getLongOptPrefix()) .append(o.getLongOpt()); } else { optBuf.append(mainOption ? lpad : lpadParam).append(getOptPrefix()).append(o.getOpt()); if (o.hasLongOpt()) { optBuf.append(',').append(getLongOptPrefix()).append(o.getLongOpt()); } } if (o.hasArg()) { String argName = o.getArgName(); if (argName != null && argName.length() == 0) { // if the option has a blank argname optBuf.append(' '); } else { optBuf.append(o.hasLongOpt() ? longOptSeparator : " "); optBuf.append("<").append(argName != null ? o.getArgName() : getArgName()).append(">"); } } o.setHelpPrefix(optBuf); maxPrefixLength = Math.max(optBuf.length(), maxPrefixLength); if (skipOption) { //TODO need better check (required option should go first and should not be duplicated continue; } String grp = o.getGroup(); grp = grp == null ? GENERAL_OPTION_GROUP : grp; String[] grps = grp.split(","); for (String g : grps) { map.get(g).add(o); } } for (Map.Entry<String, List<OmOption>> me : map.entrySet()) { final String key = me.getKey(); List<OmOption> options = me.getValue(); Collections.sort(options, new Comparator<OmOption>() { @Override public int compare(OmOption o1, OmOption o2) { boolean o1opt = !o1.isOptional(key); boolean o2opt = !o2.isOptional(key); return (o1opt && o2opt || !o1opt && !o2opt) ? (o1.getOpt() == null ? 1 : -1) : (o1opt ? -1 : 1); } }); if (opts.hasOption(key)) { options.add(0, (OmOption) opts.getOption(key)); } } return map; }
From source file:me.fireant.photoselect.persenter.PhotoSelectPersenterImpl.java
@Override public void loadFolder() { this.mLoaderManager.initLoader(1000, null, new LoaderManager.LoaderCallbacks<Cursor>() { @Override// w ww.java2 s .c om public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; return new CursorLoader(mContext, uri, projection, "", null, MediaStore.Images.Media.DATE_MODIFIED + " DESC"); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (loader == null) { return; } // ?? // <??> LinkedHashMap<String, Folder> folders = new LinkedHashMap<>(); Folder allPhotoFolder = new Folder(""); folders.put(allPhotoFolder.getFolderName(), allPhotoFolder); while (cursor.moveToNext()) { String name = cursor .getString(cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME)); String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA)); Photo photoInfo = new Photo(path); // if (!folders.containsKey(name)) { Folder newFolder = new Folder(name); folders.put(name, newFolder); } // folders.get(name).addPhoto(photoInfo); // allPhotoFolder.addPhoto(photoInfo); } ArrayList<Folder> folderData = new ArrayList<>(); for (Folder folder : folders.values()) { folderData.add(folder); } if (folderData != null) { mMvpView.showFolder(folderData); } } @Override public void onLoaderReset(Loader<Cursor> loader) { } }); }