Skip to content

Commit

Permalink
[GSCOLLECT-317] Implement Multimap.forEachKeyMultiValues().
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://gscollections.svn.services.gs.com/svnroot/gscollections-svn/trunk@674 d5c9223b-1aff-41ac-aadd-f810b4a99ac4
  • Loading branch information
nikhilnanivadekar committed Oct 15, 2014
1 parent 77afe21 commit c02f3fd
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* implementing set semantics would not. The value collections can never be empty.
* <p>
* <p>Internal iteration methods for keys and values (singly - {@link #forEachKey(Procedure)}, {@link
* #forEachValue(Procedure)}, and together - {@link #forEachKeyValue(Procedure2)}), {@link #forEachKeyMultiValue(Procedure2)}) are provided to allow flexible
* #forEachValue(Procedure)}, and together - {@link #forEachKeyValue(Procedure2)}), {@link #forEachKeyMultiValues(Procedure2)}) are provided to allow flexible
* browsing of the collection's contents. Similarly, views also are provided for keys ({@link #keysView()}), values
* ({@link #valuesView()}) and the combination thereof ({@link #keyValuePairsView()}, {@link
* #keyMultiValuePairsView()}).
Expand Down Expand Up @@ -124,7 +124,7 @@ public interface Multimap<K, V>
*
* @since 6.0
*/
void forEachKeyMultiValue(Procedure2<K, ? super Iterable<V>> procedure);
void forEachKeyMultiValues(Procedure2<K, ? super Iterable<V>> procedure);

/**
* Returns the number of key-value entry pairs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void value(K key, C collection)
});
}

public void forEachKeyMultiValue(Procedure2<K, ? super Iterable<V>> procedure)
public void forEachKeyMultiValues(Procedure2<K, ? super Iterable<V>> procedure)
{
this.getMap().forEachKeyValue(procedure);
}
Expand Down Expand Up @@ -298,7 +298,7 @@ public boolean accept(V value)

public <R extends MutableMultimap<K, V>> R selectKeysMultiValues(final Predicate2<? super K, ? super Iterable<V>> predicate, final R target)
{
this.forEachKeyMultiValue(new Procedure2<K, Iterable<V>>()
this.forEachKeyMultiValues(new Procedure2<K, Iterable<V>>()
{
public void value(K key, Iterable<V> collection)
{
Expand All @@ -313,7 +313,7 @@ public void value(K key, Iterable<V> collection)

public <R extends MutableMultimap<K, V>> R rejectKeysMultiValues(final Predicate2<? super K, ? super Iterable<V>> predicate, final R target)
{
this.forEachKeyMultiValue(new Procedure2<K, Iterable<V>>()
this.forEachKeyMultiValues(new Procedure2<K, Iterable<V>>()
{
public void value(K key, Iterable<V> collection)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,7 @@ public static <T, V extends Comparable<? super V>> T minBy(Iterable<T> iterable,
public static <K, V> HashBagMultimap<V, K> flip(BagMultimap<K, V> bagMultimap)
{
final HashBagMultimap<V, K> result = new HashBagMultimap<V, K>();
bagMultimap.forEachKeyMultiValue(new Procedure2<K, Iterable<V>>()
bagMultimap.forEachKeyMultiValues(new Procedure2<K, Iterable<V>>()
{
public void value(final K key, Iterable<V> values)
{
Expand All @@ -3170,7 +3170,7 @@ public void value(V value)
public static <K, V> HashBagMultimap<V, K> flip(ListMultimap<K, V> listMultimap)
{
final HashBagMultimap<V, K> result = new HashBagMultimap<V, K>();
listMultimap.forEachKeyMultiValue(new Procedure2<K, Iterable<V>>()
listMultimap.forEachKeyMultiValues(new Procedure2<K, Iterable<V>>()
{
public void value(final K key, Iterable<V> values)
{
Expand All @@ -3189,7 +3189,7 @@ public void value(V value)
public static <K, V> UnifiedSetMultimap<V, K> flip(SetMultimap<K, V> setMultimap)
{
final UnifiedSetMultimap<V, K> result = new UnifiedSetMultimap<V, K>();
setMultimap.forEachKeyMultiValue(new Procedure2<K, Iterable<V>>()
setMultimap.forEachKeyMultiValues(new Procedure2<K, Iterable<V>>()
{
public void value(final K key, Iterable<V> values)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void forEachKeyMultiValue()
MutableSet<Pair<Integer, Iterable<String>>> collection = UnifiedSet.newSet();
Multimap<Integer, String> multimap =
this.newMultimapWithKeysValues(2, "2", 2, "1", 3, "3", 3, "3");
multimap.forEachKeyMultiValue((key, values) -> collection.add(Tuples.pair(key, values)));
multimap.forEachKeyMultiValues((key, values) -> collection.add(Tuples.pair(key, values)));
Assert.assertEquals(UnifiedSet.newSetWith(Tuples.pair(2, this.createCollection("2", "1")), Tuples.pair(3, this.createCollection("3", "3"))), collection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void forEachKeyMultiValue()
multimap.put("Two", 1);
multimap.put("Three", 3);
multimap.put("Three", 3);
multimap.toImmutable().forEachKeyMultiValue((key, values) -> collection.add(Tuples.pair(key, values)));
multimap.toImmutable().forEachKeyMultiValues((key, values) -> collection.add(Tuples.pair(key, values)));
Assert.assertEquals(UnifiedSet.newSetWith(Tuples.pair("Two", HashBag.newBagWith(2, 1)), Tuples.pair("Three", HashBag.newBagWith(3, 3))), collection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void forEachKeyMultiValue()
multimap.put("Two", 1);
multimap.put("Three", 3);
multimap.put("Three", 3);
multimap.toImmutable().forEachKeyMultiValue((key, values) -> collection.add(Tuples.pair(key, values)));
multimap.toImmutable().forEachKeyMultiValues((key, values) -> collection.add(Tuples.pair(key, values)));
Assert.assertEquals(UnifiedSet.newSetWith(Tuples.pair("Two", FastList.newListWith(2, 1)), Tuples.pair("Three", FastList.newListWith(3, 3))), collection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void forEachKeyMultiValue()
multimap.put("Three", 3);
multimap.put("Three", 3);
ImmutableSetMultimap<String, Integer> immutableMultimap = multimap.toImmutable();
immutableMultimap.forEachKeyMultiValue((key, values) -> collection.add(Tuples.pair(key, values)));
immutableMultimap.forEachKeyMultiValues((key, values) -> collection.add(Tuples.pair(key, values)));
Assert.assertEquals(UnifiedSet.newSetWith(Tuples.pair("Two", UnifiedSet.newSetWith(2, 1)), Tuples.pair("Three", UnifiedSet.newSetWith(3, 3))), collection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void forEachKeyMultiValue()
multimap.put("Two", 1);
multimap.put("Three", 3);
multimap.put("Three", 3);
multimap.toImmutable().forEachKeyMultiValue((key, values) -> collection.add(Tuples.pair(key, values)));
multimap.toImmutable().forEachKeyMultiValues((key, values) -> collection.add(Tuples.pair(key, values)));
Assert.assertEquals(UnifiedSet.newSetWith(Tuples.pair("Two", TreeSortedSet.newSetWith(Comparators.<Integer>reverseNaturalOrder(), 2, 1)), Tuples.pair("Three", TreeSortedSet.newSetWith(Comparators.<Integer>reverseNaturalOrder(), 3, 3))), collection);
}

Expand Down

0 comments on commit c02f3fd

Please sign in to comment.