@Override public Set<String> getTagValues(String tag) { return (m_tags.get(tag)); } }
@Override public Set<String> getTagValues(String tag) { return (tags.get(tag)); }
@Override protected Set<String> create(String[] elements) { TreeMultimap<Integer, String> multimap = TreeMultimap.create(Ordering.natural(), Ordering.natural().nullsFirst()); multimap.putAll(1, Arrays.asList(elements)); return multimap.get(1); }
for (Integer key : contextMultimap.keySet()) { int valueIdx = 0; NavigableSet<KeyValue<Integer, Double>> thatValue = thatList.getContextMultimap().get(key); if (thatValue != null) { Iterator<KeyValue<Integer, Double>> contextIte = contextMultimap.get(key).iterator(); Iterator<KeyValue<Integer, Double>> thatContextIte = thatValue.iterator(); while (contextIte.hasNext() && thatContextIte.hasNext()) {
/** * Test that creating one TreeMultimap from another does not copy the comparators from the source * TreeMultimap. */ public void testCreateFromTreeMultimap() { Multimap<Double, Double> tree = TreeMultimap.create(KEY_COMPARATOR, VALUE_COMPARATOR); tree.put(1.0, 2.0); tree.put(2.0, 3.0); tree.put(3.0, 4.0); tree.put(4.0, 5.0); TreeMultimap<Double, Double> copyFromTree = TreeMultimap.create(tree); assertEquals(tree, copyFromTree); assertSame(Ordering.natural(), copyFromTree.keyComparator()); assertSame(Ordering.natural(), copyFromTree.valueComparator()); assertSame(Ordering.natural(), copyFromTree.get(1.0).comparator()); }
/** Test that a TreeMultimap created from another uses the natural ordering. */ public void testMultimapCreateFromTreeMultimap() { TreeMultimap<String, Integer> tree = TreeMultimap.create(StringLength.COMPARATOR, DECREASING_INT_COMPARATOR); tree.put("google", 2); tree.put("google", 6); tree.put("tree", 0); tree.put("tree", 3); assertThat(tree.keySet()).containsExactly("tree", "google").inOrder(); assertThat(tree.get("google")).containsExactly(6, 2).inOrder(); TreeMultimap<String, Integer> copy = TreeMultimap.create(tree); assertEquals(tree, copy); assertThat(copy.keySet()).containsExactly("google", "tree").inOrder(); assertThat(copy.get("google")).containsExactly(2, 6).inOrder(); assertEquals(Ordering.natural(), copy.keyComparator()); assertEquals(Ordering.natural(), copy.valueComparator()); assertEquals(Ordering.natural(), copy.get("google").comparator()); }
/** * * @param topN * @return */ public RecommendedList transform(int topN) { int contextIdx = 0; for(Integer key : contextMultimap.keySet()){ int valueIdx = 0; for(KeyValue<Integer, Double> value : contextMultimap.get(key)){ addList(new ArrayList<>()); if (topN < 0) { add(contextIdx, valueIdx, value.getValue()); } else { if (topN > valueIdx){ add(contextIdx, valueIdx, value.getValue()); } else { break; } } valueIdx++; } contextIdx++; } return this; }
NavigableSet<InnerObserver<T>> nextObservers = nextValues.get( lowestKey );
/** Test that creating one TreeMultimap from a SortedSetMultimap uses natural ordering. */ public void testCreateFromSortedSetMultimap() { SortedSetMultimap<Double, Double> tree = TreeMultimap.create(KEY_COMPARATOR, VALUE_COMPARATOR); tree.put(1.0, 2.0); tree.put(2.0, 3.0); tree.put(3.0, 4.0); tree.put(4.0, 5.0); SortedSetMultimap<Double, Double> sorted = Multimaps.unmodifiableSortedSetMultimap(tree); TreeMultimap<Double, Double> copyFromSorted = TreeMultimap.create(sorted); assertEquals(tree, copyFromSorted); assertSame(Ordering.natural(), copyFromSorted.keyComparator()); assertSame(Ordering.natural(), copyFromSorted.valueComparator()); assertSame(Ordering.natural(), copyFromSorted.get(1.0).comparator()); }
/** * Adds an object to the results of the search as long as maxCapacity nor maxDistance is not exceeded. * * @param entry The object to add to the results of the search */ void addEntry(Entry<T> entry) { results.put(entry.distance, entry); int size = results.size(); if (size > maxCapacity) { //Removes some entries if maxCapacity is exceeded Float maxDistanceInResults = results.keySet().last(); NavigableSet<Entry<T>> entriesAtThisDistance = results.get(maxDistanceInResults); entriesAtThisDistance.pollLast(); if (entriesAtThisDistance.size() == 0) { results.removeAll(maxDistanceInResults); } maxDistance = results.keySet().last(); } else if (size == maxCapacity) { //If the size is at maxCapacity, then set maxDistance to the distance of the last entry maxDistance = results.keySet().last(); } } }
List<String> vals = new ArrayList<>(result.get(key)); String v = String.join("|", vals); if (v.length() == 0) {
/** * Checks whether the given artifact is on the excluded list. * * @param artifact the artifact * @return {@literal true} if the artifact is excluded, {@literal false} otherwise */ public static boolean isExcluded(Artifact artifact) { Set<String> excluded = EXCLUSIONS.get(artifact.getGroupId()); return excluded != null && excluded.contains(artifact.getArtifactId()); } }
/** * Get the MFS from a lemma#posClass entry, e.g., house#n. * @param mfsMap map to get the MFS from * @return the most frequent sense */ public String getMFS(TreeMultimap<Integer, String> mfsMap) { SortedSet<String> mfs = mfsMap.get(mfsMap.keySet().first()); return mfs.first(); }
public void addOffsets(TreeMultimap<Zone,TermWeightPosition> offsetsForFields) { checkNotNull(offsetsForFields); for (Zone field : offsetsForFields.keySet()) { addOffsets(field, offsetsForFields.get(field)); } }
public static void update(HashMap<String, byte[]> dictionary, TreeMultimap<String, byte[]> tokenUp) { for (String label : tokenUp.keySet()) { dictionary.put(label, tokenUp.get(label).first()); } }
public static void update(ConcurrentMap<String, byte[]> dictionary, TreeMultimap<String, byte[]> tokenUp) { for (String label : tokenUp.keySet()) { dictionary.put(label, tokenUp.get(label).first()); } }
private SortedSet<Integer> createAndAddContainer(PacketBuffer input, int type, int containerId, int start) { C container = factory.createContainer(type); try { if (container instanceof ICustomCreateData) ((ICustomCreateData)container).readCustomDataFromStream(input); } catch (IOException e) { throw new ConsistencyCheckFailed(e, "Failed to read element %d, type %d", containerId, type); } if (containerToElement.containsEntry(containerId, start)) throw new ConsistencyCheckFailed("Container %d already exists", containerId); addContainer(containerId, container, start); return containerToElement.get(containerId); }