@Override public Set<String> getTagNames() { return (tags.keySet()); }
@Override public Set<String> getTagNames() { return (m_tags.keySet()); }
@Override protected NavigableSet<String> create(String[] elements) { TreeMultimap<String, Integer> multimap = TreeMultimap.create(Ordering.natural().nullsFirst(), Ordering.natural()); for (int i = 0; i < elements.length; i++) { multimap.put(elements[i], i); } return multimap.keySet(); }
public void testSortedKeySet() { TreeMultimap<String, Integer> multimap = createPopulate(); SortedSet<String> keySet = multimap.keySet(); assertEquals(null, keySet.first()); assertEquals("google", keySet.last()); assertEquals(StringLength.COMPARATOR, keySet.comparator()); assertEquals(Sets.newHashSet(null, "tree"), keySet.headSet("yahoo")); assertEquals(Sets.newHashSet("google"), keySet.tailSet("yahoo")); assertEquals(Sets.newHashSet("tree"), keySet.subSet("ask", "yahoo")); }
public void testOrderedKeySet() { TreeMultimap<String, Integer> multimap = createPopulate(); assertThat(multimap.keySet()).containsExactly("foo", "google", "tree").inOrder(); }
public void testOrderedKeySet() { TreeMultimap<String, Integer> multimap = createPopulate(); assertThat(multimap.keySet()).containsExactly(null, "tree", "google").inOrder(); }
/** * 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(); } } }
this.elementData.parallelStream().forEach(keyValue -> keyValue = null); thatList.elementData.parallelStream().forEach(keyValue -> keyValue = null); for (Integer key : contextMultimap.keySet()) { int valueIdx = 0; NavigableSet<KeyValue<Integer, Double>> thatValue = thatList.getContextMultimap().get(key);
/** * * @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; }
final T lowestKey = nextValues.keySet().first();
public void testTailSetClear() { TreeMultimap<String, Integer> multimap = TreeMultimap.create(); multimap.put("a", 1); multimap.put("a", 11); multimap.put("b", 2); multimap.put("c", 3); multimap.put("d", 4); multimap.put("e", 5); multimap.put("e", 55); multimap.keySet().tailSet("d").clear(); assertEquals(ImmutableSet.of("a", "b", "c"), multimap.keySet()); assertEquals(4, multimap.size()); assertEquals(4, multimap.values().size()); assertEquals(4, multimap.keys().size()); }
/** 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()); }
@GwtIncompatible // SerializableTester public void testExplicitComparatorSerialization() { TreeMultimap<String, Integer> multimap = createPopulate(); TreeMultimap<String, Integer> copy = SerializableTester.reserializeAndAssert(multimap); assertThat(copy.values()).containsExactly(7, 3, 1, null, 0, 6, 2).inOrder(); assertThat(copy.keySet()).containsExactly(null, "tree", "google").inOrder(); assertEquals(multimap.keyComparator(), copy.keyComparator()); assertEquals(multimap.valueComparator(), copy.valueComparator()); } }
@GwtIncompatible // SerializableTester public void testExplicitComparatorSerialization() { TreeMultimap<String, Integer> multimap = createPopulate(); TreeMultimap<String, Integer> copy = SerializableTester.reserializeAndAssert(multimap); assertThat(copy.values()).containsExactly(1, 3, 7, 2, 6, 0, 4).inOrder(); assertThat(copy.keySet()).containsExactly("foo", "google", "tree").inOrder(); assertEquals(multimap.keyComparator(), copy.keyComparator()); assertEquals(multimap.valueComparator(), copy.valueComparator()); }
@GwtIncompatible // SerializableTester public void testTreeMultimapNonGeneric() { TreeMultimap<LegacyComparable, LegacyComparable> multimap = TreeMultimap.create(); assertEquals(ImmutableMultimap.of(), multimap); multimap.put(new LegacyComparable("foo"), new LegacyComparable("f")); multimap.put(new LegacyComparable("foo"), new LegacyComparable("o")); multimap.put(new LegacyComparable("foo"), new LegacyComparable("o")); multimap.put(new LegacyComparable("bar"), new LegacyComparable("b")); multimap.put(new LegacyComparable("bar"), new LegacyComparable("a")); multimap.put(new LegacyComparable("bar"), new LegacyComparable("r")); assertThat(multimap.keySet()) .containsExactly(new LegacyComparable("bar"), new LegacyComparable("foo")) .inOrder(); assertThat(multimap.values()) .containsExactly( new LegacyComparable("a"), new LegacyComparable("b"), new LegacyComparable("r"), new LegacyComparable("f"), new LegacyComparable("o")) .inOrder(); assertEquals(Ordering.natural(), multimap.keyComparator()); assertEquals(Ordering.natural(), multimap.valueComparator()); SerializableTester.reserializeAndAssert(multimap); }
@GwtIncompatible // SerializableTester public void testTreeMultimapDerived() { TreeMultimap<DerivedComparable, DerivedComparable> multimap = TreeMultimap.create(); assertEquals(ImmutableMultimap.of(), multimap); multimap.put(new DerivedComparable("foo"), new DerivedComparable("f")); multimap.put(new DerivedComparable("foo"), new DerivedComparable("o")); multimap.put(new DerivedComparable("foo"), new DerivedComparable("o")); multimap.put(new DerivedComparable("bar"), new DerivedComparable("b")); multimap.put(new DerivedComparable("bar"), new DerivedComparable("a")); multimap.put(new DerivedComparable("bar"), new DerivedComparable("r")); assertThat(multimap.keySet()) .containsExactly(new DerivedComparable("bar"), new DerivedComparable("foo")) .inOrder(); assertThat(multimap.values()) .containsExactly( new DerivedComparable("a"), new DerivedComparable("b"), new DerivedComparable("r"), new DerivedComparable("f"), new DerivedComparable("o")) .inOrder(); assertEquals(Ordering.natural(), multimap.keyComparator()); assertEquals(Ordering.natural(), multimap.valueComparator()); SerializableTester.reserializeAndAssert(multimap); }
for (String key : result.keySet()) { List<String> vals = new ArrayList<>(result.get(key)); String v = String.join("|", vals);
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 void printMap(Multimap<String,String> fieldMap) { TreeMultimap<String,String> sorted = TreeMultimap.create(fieldMap); for (String key : sorted.keySet()) { System.out.print(key + ": "); Collection<String> values = fieldMap.get(key); for (String value : values) { System.out.print("[" + value + "]"); } System.out.print("\n"); } System.out.println(); }
public void testSortedKeySet() { TreeMultimap<String, Integer> multimap = createPopulate(); SortedSet<String> keySet = multimap.keySet(); assertEquals(null, keySet.first()); assertEquals("google", keySet.last()); assertEquals(StringLength.COMPARATOR, keySet.comparator()); assertEquals(Sets.newHashSet(null, "tree"), keySet.headSet("yahoo")); assertEquals(Sets.newHashSet("google"), keySet.tailSet("yahoo")); assertEquals(Sets.newHashSet("tree"), keySet.subSet("ask", "yahoo")); }