forked from jasder/antlr
add useful method to get a->b pairs out
This commit is contained in:
parent
41be88dcd5
commit
e9a3de645a
|
@ -29,6 +29,8 @@
|
|||
|
||||
package org.antlr.v4.runtime.misc;
|
||||
|
||||
import com.sun.tools.javac.util.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
@ -42,4 +44,14 @@ public class MultiMap<K, V> extends LinkedHashMap<K, List<V>> {
|
|||
}
|
||||
elementsForKey.add(value);
|
||||
}
|
||||
|
||||
public List<Pair<K,V>> getPairs() {
|
||||
List<Pair<K,V>> pairs = new ArrayList<Pair<K,V>>();
|
||||
for (K key : keySet()) {
|
||||
for (V value : get(key)) {
|
||||
pairs.add(new Pair<K,V>(key, value));
|
||||
}
|
||||
}
|
||||
return pairs;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue