项目:guava-mock
文件:ImmutableSetMultimapTest.java
public void testBuilder_withMutableEntry() {
ImmutableSetMultimap.Builder<String,Integer> builder =
new Builder<String,Integer>();
final StringHolder holder = new StringHolder();
holder.string = "one";
Entry<String,Integer> entry = new AbstractMapEntry<String,Integer>() {
@Override public String getKey() {
return holder.string;
}
@Override public Integer getValue() {
return 1;
}
};
builder.put(entry);
holder.string = "two";
assertEquals(ImmutableSet.of(1),builder.build().get("one"));
}
项目:guava-mock
文件:ImmutableSetMultimapTest.java
public void testBuilderPutAllMultimap() {
Multimap<String,Integer> toPut = LinkedListMultimap.create();
toPut.put("foo",1);
toPut.put("bar",4);
toPut.put("foo",2);
toPut.put("foo",3);
Multimap<String,Integer> moretoPut = LinkedListMultimap.create();
moretoPut.put("foo",6);
moretoPut.put("bar",5);
moretoPut.put("foo",7);
ImmutableSetMultimap.Builder<String,Integer> builder
= ImmutableSetMultimap.builder();
builder.putAll(toPut);
builder.putAll(moretoPut);
Multimap<String,Integer> multimap = builder.build();
assertEquals(ImmutableSet.of(1,2,3,6,7),multimap.get("foo"));
assertEquals(ImmutableSet.of(4,5),multimap.get("bar"));
assertEquals(7,multimap.size());
}
项目:guava-mock
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderKeysBy() {
ImmutableSetMultimap.Builder<String,Integer> builder
= ImmutableSetMultimap.builder();
builder.put("b",3);
builder.put("d",2);
builder.put("a",5);
builder.orderKeysBy(Collections.reverSEOrder());
builder.put("c",4);
builder.put("a",2);
builder.put("b",6);
ImmutableSetMultimap<String,Integer> multimap = builder.build();
assertthat(multimap.keySet()).containsExactly("d","c","b","a").inorder();
assertthat(multimap.values()).containsExactly(2,4,5,2).inorder();
assertthat(multimap.get("a")).containsExactly(5,2).inorder();
assertthat(multimap.get("b")).containsExactly(3,6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
项目:guava-mock
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderKeysByDuplicates() {
ImmutableSetMultimap.Builder<String,Integer> builder
= ImmutableSetMultimap.builder();
builder.put("bb",5);
builder.orderKeysBy(new Ordering<String>() {
@Override
public int compare(String left,String right) {
return left.length() - right.length();
}
});
builder.put("cc",2);
builder.put("bb","a","bb","cc").inorder();
assertthat(multimap.values()).containsExactly(2,4).inorder();
assertthat(multimap.get("a")).containsExactly(5,2).inorder();
assertthat(multimap.get("bb")).containsExactly(3,6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
项目:guava-mock
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderValuesBy() {
ImmutableSetMultimap.Builder<String,5);
builder.orderValuesBy(Collections.reverSEOrder());
builder.put("c",Integer> multimap = builder.build();
assertthat(multimap.keySet()).containsExactly("b","d","c").inorder();
assertthat(multimap.values()).containsExactly(6,2).inorder();
assertthat(multimap.get("b")).containsExactly(6,3).inorder();
assertTrue(multimap.get("a") instanceof ImmutableSortedSet);
assertEquals(Collections.reverSEOrder(),((ImmutableSortedSet<Integer>) multimap.get("a")).comparator());
assertTrue(multimap.get("x") instanceof ImmutableSortedSet);
assertEquals(Collections.reverSEOrder(),((ImmutableSortedSet<Integer>) multimap.get("x")).comparator());
assertTrue(multimap.asMap().get("a") instanceof ImmutableSortedSet);
assertEquals(Collections.reverSEOrder(),((ImmutableSortedSet<Integer>) multimap.asMap().get("a")).comparator());
}
项目:guava-mock
文件:ImmutableSetMultimapTest.java
项目:guava-mock
文件:ImmutableSetMultimapTest.java
@GwtIncompatible // SerializableTester
public void testSortedSerialization() {
Multimap<String,Integer> multimap = new ImmutableSetMultimap.Builder<String,Integer>()
.orderKeysBy(Ordering.natural().reverse())
.orderValuesBy(Ordering.usingToString())
.put("a",2)
.put("a",10)
.put("b",1)
.build();
multimap = SerializableTester.reserialize(multimap);
assertthat(multimap.keySet()).containsExactly("b","a").inorder();
assertthat(multimap.get("a")).containsExactly(10,2).inorder();
assertEquals(Ordering.usingToString(),((ImmutableSortedSet<Integer>) multimap.get("a")).comparator());
assertEquals(Ordering.usingToString(),((ImmutableSortedSet<Integer>) multimap.get("z")).comparator());
}
项目:athena
文件:DefaultTopology.java
/**
* Computes on-demand the set of shortest paths between source and
* destination devices.
*
* @param src source device
* @param dst destination device
* @param weight link weight function
* @return set of shortest paths
*/
public Set<Path> getPaths(deviceid src,deviceid dst,LinkWeight weight) {
DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
// src or dst not part of the current graph
return ImmutableSet.of();
}
GraPHPathSearch.Result<TopologyVertex,TopologyEdge> result =
graPHPathSearch().search(graph,srcV,dstV,weight,ALL_PATHS);
ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex,TopologyEdge> path : result.paths()) {
builder.add(networkPath(path));
}
return builder.build();
}
项目:athena
文件:DefaultTopology.java
/**
* Computes on-demand the set of shortest disjoint path pairs between source and
* destination devices.
*
* @param src source device
* @param dst destination device
* @param weight link weight function
* @return set of disjoint shortest path pairs
*/
public Set<disjointPath> getdisjointPaths(deviceid src,TopologyEdge> result =
SUURBALLE.search(graph,ALL_PATHS);
ImmutableSet.Builder<disjointPath> builder = ImmutableSet.builder();
for (org.onlab.graph.Path<TopologyVertex,TopologyEdge> path : result.paths()) {
builder.add(networkdisjointPath((org.onlab.graph.disjointPathPair<TopologyVertex,TopologyEdge>) path));
}
return builder.build();
}
项目:athena
文件:DefaultTopology.java
/**
* Computes on-demand the set of shortest disjoint risk groups path pairs between source and
* destination devices.
*
* @param src source device
* @param dst destination device
* @param weight edge weight object
* @param riskProfile map representing risk groups for each edge
* @return set of shortest disjoint paths
*/
private Set<disjointPath> disjointPaths(deviceid src,LinkWeight weight,Map<TopologyEdge,Object> riskProfile) {
DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
// src or dst not part of the current graph
return ImmutableSet.of();
}
SrlgGraphSearch<TopologyVertex,TopologyEdge> srlg = new SrlgGraphSearch<>(riskProfile);
GraPHPathSearch.Result<TopologyVertex,TopologyEdge> result =
srlg.search(graph,TopologyEdge>) path));
}
return builder.build();
}
项目:athena
文件:DefaultTopology.java
private ImmutableMap<ClusterId,TopologyCluster> buildTopologyClusters() {
ImmutableMap.Builder<ClusterId,TopologyCluster> clusterBuilder = ImmutableMap.builder();
SccResult<TopologyVertex,TopologyEdge> results = clusterResults.get();
// Extract both vertexes and edges from the results; the lists form
// pairs along the same index.
List<Set<TopologyVertex>> clusterVertexes = results.clusterVertexes();
List<Set<TopologyEdge>> clusterEdges = results.clusterEdges();
// Scan over the lists and create a cluster from the results.
for (int i = 0,n = results.clusterCount(); i < n; i++) {
Set<TopologyVertex> vertexSet = clusterVertexes.get(i);
Set<TopologyEdge> edgeSet = clusterEdges.get(i);
ClusterId cid = ClusterId.clusterId(i);
DefaultTopologyCluster cluster = new DefaultTopologyCluster(cid,vertexSet.size(),edgeSet.size(),findRoot(vertexSet));
clusterBuilder.put(cid,cluster);
}
return clusterBuilder.build();
}
public void testBuilder_withMutableEntry() {
ImmutableSetMultimap.Builder<String,builder.build().get("one"));
}
public void testBuilderPutAllMultimap() {
Multimap<String,multimap.size());
}
public void testBuilderOrderKeysBy() {
ImmutableSetMultimap.Builder<String,6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
public void testBuilderOrderKeysByDuplicates() {
ImmutableSetMultimap.Builder<String,6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
public void testBuilderOrderValuesBy() {
ImmutableSetMultimap.Builder<String,((ImmutableSortedSet<Integer>) multimap.asMap().get("a")).comparator());
}
public void testBuilderOrderKeysAndValuesBy() {
ImmutableSetMultimap.Builder<String,((ImmutableSortedSet<Integer>) multimap.asMap().get("a")).comparator());
}
@GwtIncompatible // SerializableTester
public void testSortedSerialization() {
Multimap<String,((ImmutableSortedSet<Integer>) multimap.get("z")).comparator());
}
/**
* Computes on-demand the set of shortest paths between source and
* destination devices.
*
* @param src source device
*
* @param dst destination device
*
* @param weight link weight function
*
* @return set of shortest paths
*/
Set<Path> getPaths(deviceid src,LinkWeight weight) {
final DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
final DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
// src or dst not part of the current graph
return ImmutableSet.of();
}
GraPHPathSearch.Result<TopologyVertex,TopologyEdge> result =
DIJKSTRA.search(graph,TopologyEdge> path : result.paths()) {
builder.add(networkPath(path));
}
return builder.build();
}
private ImmutableMap<ClusterId,TopologyCluster> clusterBuilder = ImmutableMap.builder();
SCCResult<TopologyVertex,TopologyEdge> results = clusterResults.get();
// Extract both vertexes and edges from the results; the lists form
// pairs along the same index.
List<Set<TopologyVertex>> clusterVertexes = results.clusterVertexes();
List<Set<TopologyEdge>> clusterEdges = results.clusterEdges();
// Scan over the lists and create a cluster from the results.
for (int i = 0,cluster);
}
return clusterBuilder.build();
}
项目:guava-libraries
文件:ImmutableSetMultimapTest.java
public void testBuilder_withMutableEntry() {
ImmutableSetMultimap.Builder<String,builder.build().get("one"));
}
项目:guava-libraries
文件:ImmutableSetMultimapTest.java
public void testBuilderPutAllMultimap() {
Multimap<String,multimap.size());
}
项目:guava-libraries
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderKeysBy() {
ImmutableSetMultimap.Builder<String,6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
项目:guava-libraries
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderKeysByDuplicates() {
ImmutableSetMultimap.Builder<String,6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
项目:guava-libraries
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderValuesBy() {
ImmutableSetMultimap.Builder<String,((ImmutableSortedSet<Integer>) multimap.asMap().get("a")).comparator());
}
项目:guava-libraries
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderKeysAndValuesBy() {
ImmutableSetMultimap.Builder<String,((ImmutableSortedSet<Integer>) multimap.asMap().get("a")).comparator());
}
项目:guava-libraries
文件:ImmutableSetMultimapTest.java
@GwtIncompatible("SerializableTester")
public void testSortedSerialization() {
Multimap<String,((ImmutableSortedSet<Integer>) multimap.get("z")).comparator());
}
项目:guava
文件:ImmutableSetMultimapTest.java
public void testBuilder_withMutableEntry() {
ImmutableSetMultimap.Builder<String,Integer> builder = new Builder<>();
final StringHolder holder = new StringHolder();
holder.string = "one";
Entry<String,Integer> entry =
new AbstractMapEntry<String,Integer>() {
@Override
public String getKey() {
return holder.string;
}
@Override
public Integer getValue() {
return 1;
}
};
builder.put(entry);
holder.string = "two";
assertEquals(ImmutableSet.of(1),builder.build().get("one"));
}
项目:guava
文件:ImmutableSetMultimapTest.java
public void testBuilderPutAllMultimap() {
Multimap<String,Integer> builder = ImmutableSetMultimap.builder();
builder.putAll(toPut);
builder.putAll(moretoPut);
Multimap<String,multimap.size());
}
项目:guava
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderKeysBy() {
ImmutableSetMultimap.Builder<String,Integer> builder = ImmutableSetMultimap.builder();
builder.put("b",6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
项目:guava
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderKeysByDuplicates() {
ImmutableSetMultimap.Builder<String,Integer> builder = ImmutableSetMultimap.builder();
builder.put("bb",5);
builder.orderKeysBy(
new Ordering<String>() {
@Override
public int compare(String left,String right) {
return left.length() - right.length();
}
});
builder.put("cc",6).inorder();
assertFalse(multimap.get("a") instanceof ImmutableSortedSet);
assertFalse(multimap.get("x") instanceof ImmutableSortedSet);
assertFalse(multimap.asMap().get("a") instanceof ImmutableSortedSet);
}
项目:guava
文件:ImmutableSetMultimapTest.java
public void testBuilderOrderValuesBy() {
ImmutableSetMultimap.Builder<String,3).inorder();
assertTrue(multimap.get("a") instanceof ImmutableSortedSet);
assertEquals(
Collections.reverSEOrder(),((ImmutableSortedSet<Integer>) multimap.get("a")).comparator());
assertTrue(multimap.get("x") instanceof ImmutableSortedSet);
assertEquals(
Collections.reverSEOrder(),((ImmutableSortedSet<Integer>) multimap.get("x")).comparator());
assertTrue(multimap.asMap().get("a") instanceof ImmutableSortedSet);
assertEquals(
Collections.reverSEOrder(),((ImmutableSortedSet<Integer>) multimap.asMap().get("a")).comparator());
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。