public static BiMap<String, Integer> loadString2IntegerBiMap(String file, String delimiter) throws IOException {
BiMap<String, Integer> res = HashBiMap.create();
BufferedReader reader = IOUtils.getBufferedFileReader(file);
String line;
while ((line = reader.readLine()) != null) {
String[] tokens = line.split(delimiter);
res.put(tokens[0], Integer.parseInt(tokens[1]));
}
reader.close();
return res;
}
java类com.google.common.collect.BiMap的实例源码
FileUtils.java 文件源码
项目:TextHIN
阅读 34
收藏 0
点赞 0
评论 0
ProblemNodeMappingGraph.java 文件源码
项目:SubgraphIsomorphismIndex
阅读 32
收藏 0
点赞 0
评论 0
public ProblemNodeMappingGraph(
BiMap<V, V> baseSolution,
G viewGraph,
G queryGraph,
Function<BiMap<V, V>, Comparator<V>> nodeComparatorFactory,
Function<BiMap<V, V>, Comparator<E>> edgeComparatorFactory)
{
this(
baseSolution, viewGraph, queryGraph,
nodeComparatorFactory, edgeComparatorFactory,
true);
}
SubgraphIsomorphismIndexImpl.java 文件源码
项目:SubgraphIsomorphismIndex
阅读 49
收藏 0
点赞 0
评论 0
/**
* Lookup only pref keys / this skips results isomorphic to the given keys
* @param queryGraph
* @param exactMatch
* @return
*/
public Multimap<K, BiMap<V, V>> lookupFlat(G queryGraph, boolean exactMatch) {
Set<T> queryGraphTags = extractGraphTagsWrapper(queryGraph);
Collection<InsertPosition<K, G, V, T>> positions = new LinkedList<>();
findInsertPositions(positions, rootNode, queryGraph, queryGraphTags, HashBiMap.create(), HashBiMap.create(), true, exactMatch); //, writer);
Multimap<K, BiMap<V, V>> result = HashMultimap.create();
if(logger.isDebugEnabled()) {
logger.debug("Lookup result candidates: " + positions.size());
}
for(InsertPosition<K, G, V, T> pos : positions) {
// Match with the children
result.put(pos.getNode().getKey(), pos.getIso());
//System.out.println("Node " + pos.node + " with keys " + pos.node.getKeys() + " iso: " + pos.getGraphIso().getInToOut());
// for(K key : pos.node.getKeys()) {
// result.put(key, pos.getIso());
// }
}
return result;
}
DerivedGoogleCollectionGenerators.java 文件源码
项目:googles-monorepo-demo
阅读 29
收藏 0
点赞 0
评论 0
public BiMapValueSetGenerator(
OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> mapGenerator) {
this.mapGenerator = mapGenerator;
final SampleElements<Map.Entry<K, V>> mapSamples = this.mapGenerator.samples();
this.samples =
new SampleElements<V>(
mapSamples.e0().getValue(),
mapSamples.e1().getValue(),
mapSamples.e2().getValue(),
mapSamples.e3().getValue(),
mapSamples.e4().getValue());
}
BiMapClearTester.java 文件源码
项目:guava-mock
阅读 40
收藏 0
点赞 0
评论 0
@MapFeature.Require(SUPPORTS_REMOVE)
public void testValuesClearClearsInverse() {
BiMap<V, K> inv = getMap().inverse();
getMap().values().clear();
assertTrue(getMap().isEmpty());
assertTrue(inv.isEmpty());
}
BiMapClearTester.java 文件源码
项目:guava-mock
阅读 28
收藏 0
点赞 0
评论 0
@MapFeature.Require(SUPPORTS_REMOVE)
public void testClearInverseKeySetClears() {
BiMap<V, K> inv = getMap().inverse();
inv.keySet().clear();
assertTrue(getMap().isEmpty());
assertTrue(inv.isEmpty());
}
BiMapClearTester.java 文件源码
项目:guava-mock
阅读 24
收藏 0
点赞 0
评论 0
@MapFeature.Require(SUPPORTS_REMOVE)
public void testClearInverseValuesClears() {
BiMap<V, K> inv = getMap().inverse();
inv.values().clear();
assertTrue(getMap().isEmpty());
assertTrue(inv.isEmpty());
}
ShellBasedIdMapping.java 文件源码
项目:hadoop
阅读 36
收藏 0
点赞 0
评论 0
synchronized private void loadFullUserMap() throws IOException {
BiMap<Integer, String> uMap = HashBiMap.create();
if (OS.startsWith("Mac")) {
updateMapInternal(uMap, "user", MAC_GET_ALL_USERS_CMD, "\\s+",
staticMapping.uidMapping);
} else {
updateMapInternal(uMap, "user", GET_ALL_USERS_CMD, ":",
staticMapping.uidMapping);
}
uidNameMap = uMap;
lastUpdateTime = Time.monotonicNow();
}
BiMapInverseTester.java 文件源码
项目:googles-monorepo-demo
阅读 23
收藏 0
点赞 0
评论 0
BiMapPair(BiMap<K, V> original) {
this.forward = original;
this.backward = original.inverse();
}
GlobalMap.java 文件源码
项目:train-simulator
阅读 40
收藏 0
点赞 0
评论 0
public BiMap<Integer, JourneyPath> getJourneyPaths() {
return journeyPathsMap;
}