use of com.google.common.collect.Multiset in project Railcraft by Railcraft.
the class TileItemManipulator method processCart.
@Override
protected void processCart(EntityMinecart cart) {
chests.clear();
chests.add(invBuffer);
chests.addAll(invCache.getAdjacentInventories());
InventoryComposite cartInv = InventoryComposite.of(InventoryFactory.get(cart, getFacing().getOpposite()));
if (cartInv.isEmpty()) {
sendCart(cart);
return;
}
this.cart = cartInv;
switch(getMode()) {
case TRANSFER:
{
Multiset<StackKey> filterManifest = InvTools.createManifest(getItemFilters());
filterManifest.entrySet().stream().filter(entry -> transferredItems.count(entry.getElement()) < entry.getCount()).anyMatch(entry -> {
ItemStack moved = InvTools.moveOneItem(getSource(), getDestination(), StackFilters.matches(entry.getElement().get()));
if (!InvTools.isEmpty(moved)) {
setProcessing(true);
transferredItems.add(entry.getElement());
return true;
}
return false;
});
break;
}
case STOCK:
{
Multiset<StackKey> filterManifest = InvTools.createManifest(getItemFilters());
Multiset<StackKey> destManifest = InvTools.createManifest(getDestination(), filterManifest.elementSet());
moveItem(filterManifest.entrySet().stream().filter(entry -> destManifest.count(entry.getElement()) < entry.getCount()));
break;
}
case EXCESS:
{
Multiset<StackKey> filterManifest = InvTools.createManifest(getItemFilters());
Multiset<StackKey> sourceManifest = InvTools.createManifest(getSource(), filterManifest.elementSet());
moveItem(filterManifest.entrySet().stream().filter(entry -> sourceManifest.count(entry.getElement()) > entry.getCount()));
if (!isProcessing()) {
Predicate<ItemStack> keep = filterManifest.elementSet().stream().map(e -> StackFilters.matches(e.get())).reduce(StackFilters.none(), Predicate::or);
ItemStack moved = InvTools.moveOneItemExcept(getSource(), getDestination(), keep);
itemMoved(moved);
}
break;
}
case ALL:
{
Multiset<StackKey> filterManifest = InvTools.createManifest(getItemFilters());
if (filterManifest.isEmpty()) {
ItemStack moved = InvTools.moveOneItem(getSource(), getDestination());
itemMoved(moved);
} else {
moveItem(filterManifest.entrySet().stream());
}
break;
}
}
}
use of com.google.common.collect.Multiset in project jackrabbit-oak by apache.
the class SegmentGraphTest method testSegmentGraph.
@Test
public void testSegmentGraph() throws Exception {
ReadOnlyFileStore store = fileStoreBuilder(getStoreFolder()).buildReadOnly();
try {
Graph<UUID> segmentGraph = parseSegmentGraph(store, Predicates.<UUID>alwaysTrue());
assertEquals(segments, newHashSet(segmentGraph.vertices()));
Map<UUID, Set<UUID>> map = newHashMap();
for (Entry<UUID, Multiset<UUID>> entry : segmentGraph.edges()) {
map.put(entry.getKey(), entry.getValue().elementSet());
}
assertEquals(references, map);
} finally {
store.close();
}
}
use of com.google.common.collect.Multiset in project jackrabbit-oak by apache.
the class SegmentGraphTest method testSegmentGraphWithFilter.
@Test
public void testSegmentGraphWithFilter() throws Exception {
ReadOnlyFileStore store = fileStoreBuilder(getStoreFolder()).buildReadOnly();
try {
Predicate<UUID> filter = createRegExpFilter(".*(writer2|writer3).*", store.getSegmentIdProvider());
Graph<UUID> segmentGraph = parseSegmentGraph(store, filter);
assertEquals(filteredSegments, newHashSet(segmentGraph.vertices()));
Map<UUID, Set<UUID>> map = newHashMap();
for (Entry<UUID, Multiset<UUID>> entry : segmentGraph.edges()) {
map.put(entry.getKey(), entry.getValue().elementSet());
}
assertEquals(filteredReferences, map);
} finally {
store.close();
}
}
use of com.google.common.collect.Multiset in project hale by halestudio.
the class PropertyEntityDefinitionMapping method map.
/**
* @see eu.esdihumboldt.hale.common.instance.index.IndexMapping#map(java.lang.Object)
*/
@Override
public List<IndexedPropertyValue> map(Instance instance) {
List<IndexedPropertyValue> result = new ArrayList<>();
for (PropertyEntityDefinition definition : definitions) {
List<QName> propertyPath = definition.getPropertyPath().stream().map(cctx -> cctx.getChild().getName()).collect(Collectors.toList());
Multiset<?> values = AlignmentUtil.getValues(instance, definition, false);
result.add(new IndexedPropertyValue(propertyPath, values.elementSet().stream().map(v -> processValue(v, definition)).collect(Collectors.toList())));
}
return result;
}
use of com.google.common.collect.Multiset in project bayou by capergroup.
the class FeatureTest method testcfg.
@Test
public void testcfg() throws ParseException, IOException {
File srcFolder;
{
File projRoot = new File(System.getProperty("user.dir")).getParentFile().getParentFile().getParentFile();
srcFolder = new File(projRoot.getAbsolutePath() + File.separator + "src");
}
String testDir = srcFolder.getAbsolutePath() + File.separator + "test" + File.separator + "resources" + File.separator + "driver";
String test_filename = "skeleton1.java";
String src = read_file(testDir + File.separator + test_filename);
ASTParser parser = ASTParser.newParser(AST.JLS3);
Map options = new HashMap();
parser.setCompilerOptions(options);
parser.setSource(src.toCharArray());
parser.setKind(ASTParser.K_COMPILATION_UNIT);
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
cu.accept(new ASTVisitor() {
@Override
public boolean visit(MethodDeclaration method) {
CFGFeature feature = new CFGFeature(method);
Multiset<Integer> set = feature.gen_subgraph(4, true);
System.out.println(set.toString());
DecoratedSkeletonFeature sf = new DecoratedSkeletonFeature(method);
System.out.println(sf.toString());
return false;
}
});
}
Aggregations