List of usage examples for com.google.common.collect Multimap removeAll
Collection<V> removeAll(@Nullable Object key);
From source file:de.cau.cs.kieler.klay.layered.intermediate.SplineSelfLoopPreProcessor.java
/** * Finds a set of connected edges. Two edges are connected if they share a port, or if there * is a path between them, only containing self-loops. * //from ww w. j a va 2 s . c om * @param portsToEdges A Multimap holding all connections between the ports. * ATTENTION: THIS PARAMETER GETS ALTERED: * All edges included in the return value are removed from the Multimap. * @param node The node we are currently working on. * @param isFixedOrder True, if the port-order of the node is at least {@code fixedOrder}. * @return A set of connected edges. */ private static ConnectedSelfLoopComponent findAConnectedComponent(final Multimap<LPort, LEdge> portsToEdges, final LNode node, final boolean isFixedOrder) { final Multimap<LEdge, LPort> edgeToPort = ArrayListMultimap.create(); Multimaps.invertFrom(portsToEdges, edgeToPort); // The connected components element we are constructing. final ConnectedSelfLoopComponent connectedComponent = new ConnectedSelfLoopComponent(node); // Create a list of ports we have to check for connected ports. Initially add an arbitrary port. final List<LPort> portsToProcess = Lists.newArrayList(); portsToProcess.add(portsToEdges.keys().iterator().next()); final List<LPort> portsProcessed = Lists.newArrayList(); // Check ports for connection to current connected component till no port to check is left. while (!portsToProcess.isEmpty()) { final LPort currentPort = portsToProcess.iterator().next(); portsProcessed.add(currentPort); final Collection<LEdge> allEdgesOnCurrentPort = portsToEdges.removeAll(currentPort); for (final LEdge currentEdge : allEdgesOnCurrentPort) { if (connectedComponent.tryAddEdge(currentEdge, isFixedOrder)) { final Collection<LPort> portsOfCurrentEdge = edgeToPort.removeAll(currentEdge); for (final LPort port : portsOfCurrentEdge) { if (!portsProcessed.contains(port)) { portsToProcess.add(port); } } } } portsToProcess.remove(currentPort); } return connectedComponent; }
From source file:vazkii.botania.common.item.equipment.tool.ItemThunderSword.java
@Nonnull @Override//from ww w .ja va2 s. com public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot); if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { multimap.removeAll(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName()); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.5, 0)); } return multimap; }
From source file:org.ow2.proactive.scheduler.authentication.ManageUsers.java
private static void deleteAccount(UserInfo userInfo, String loginFilePath, String groupFilePath, Properties props, Multimap<String, String> groupsMap) throws ManageUsersException { if (!userInfo.isLoginSet()) { warnWithMessage(PROVIDED_USERNAME + IS_EMPTY_SKIPPING); return;//from ww w . ja va 2s . c o m } if (!props.containsKey(userInfo.getLogin())) { warnWithMessage(USER_HEADER + userInfo.getLogin() + DOES_NOT_EXIST_IN_LOGIN_FILE + loginFilePath); } if (!groupsMap.containsKey(userInfo.getLogin())) { warnWithMessage(USER_HEADER + userInfo.getLogin() + DOES_NOT_EXIST_IN_GROUP_FILE + groupFilePath); } props.remove(userInfo.getLogin()); groupsMap.removeAll(userInfo.getLogin()); System.out.println("Deleted user " + userInfo.getLogin()); }
From source file:org.terasology.config.InputConfig.java
/** * Sets the inputs for a given bind, replacing any previous inputs * @param packageName//from ww w. j av a 2 s. c o m * @param bindName * @param inputs */ public void setInputs(String packageName, String bindName, Input... inputs) { Multimap<String, Input> packageMap = getPackageMap(packageName); if (inputs.length == 0) { packageMap.removeAll(bindName); packageMap.put(bindName, new Input()); } else { packageMap.replaceValues(bindName, Arrays.asList(inputs)); } }
From source file:com.axelor.meta.loader.AbstractLoader.java
/** * Resolve the given unresolved key.<br> * <br>/* ww w . j a va 2 s.com*/ * All the pending values of the unresolved key are returned for further * processing. The values are removed from the backing {@link Multimap}. * * @param type * the type of pending objects * @param unresolvedKey * the unresolved key * @return a set of all the pending objects */ @SuppressWarnings("unchecked") protected <T> Set<T> resolve(Class<T> type, String unresolvedKey) { Set<T> values = Sets.newHashSet(); Map<Class<?>, Multimap<String, Object>> map = unresolved.get(); if (map == null) { return values; } Multimap<String, Object> mm = map.get(type); if (mm == null) { return values; } for (Object item : mm.get(unresolvedKey)) { values.add((T) item); } mm.removeAll(unresolvedKey); return values; }
From source file:com.cinchapi.concourse.importer.JsonImporter.java
/** * Given a string of JSON data, upsert it into Concourse. * //w w w.j a va 2 s . c o m * @param json * @return the records that were affected by the import */ protected Set<Long> upsertJsonString(String json) { // TODO call concourse.upsert(json) when method is ready // NOTE: The following implementation is very inefficient, but will // suffice until the upsert functionality is available Set<Long> records = Sets.newHashSet(); for (Multimap<String, Object> data : Convert.anyJsonToJava(json)) { Long record = MoreObjects.firstNonNull( (Long) Iterables.getOnlyElement(data.get(Constants.JSON_RESERVED_IDENTIFIER_NAME), null), Time.now()); data.removeAll(Constants.JSON_RESERVED_IDENTIFIER_NAME); for (String key : data.keySet()) { for (Object value : data.get(key)) { concourse.add(key, value, record); } } records.add(record); } return records; }
From source file:com.continuuity.weave.discovery.ZKDiscoveryService.java
private void updateService(NodeChildren children, final String service) { final String sb = "/" + service; final Multimap<String, Discoverable> newServices = HashMultimap.create(services.get()); newServices.removeAll(service); // Fetch data of all children nodes in parallel. List<OperationFuture<NodeData>> dataFutures = Lists.newArrayListWithCapacity(children.getChildren().size()); for (String child : children.getChildren()) { String path = sb + "/" + child; dataFutures.add(zkClient.getData(path)); }/*w ww . j av a 2 s . co m*/ // Update the service map when all fetching are done. final ListenableFuture<List<NodeData>> fetchFuture = Futures.successfulAsList(dataFutures); fetchFuture.addListener(new Runnable() { @Override public void run() { for (NodeData nodeData : Futures.getUnchecked(fetchFuture)) { // For successful fetch, decode the content. if (nodeData != null) { Discoverable discoverable = decode(nodeData.getData()); if (discoverable != null) { newServices.put(service, discoverable); } } } // Replace the local service register with changes. services.set(newServices); } }, Threads.SAME_THREAD_EXECUTOR); }
From source file:org.apache.storm.streams.processors.JoinProcessor.java
private <T1, T2> List<Tuple3<K, T1, T2>> join(Multimap<K, T1> tab, List<Pair<K, T2>> rows, JoinType leftType, JoinType rightType) {/*from w w w. j a v a 2 s . c om*/ List<Tuple3<K, T1, T2>> res = new ArrayList<>(); for (Pair<K, T2> row : rows) { K key = row.getFirst(); Collection<T1> values = tab.removeAll(key); if (values.isEmpty()) { if (rightType == JoinType.OUTER) { res.add(new Tuple3<>(row.getFirst(), null, row.getSecond())); } } else { for (T1 mapValue : values) { res.add(new Tuple3<>(row.getFirst(), mapValue, row.getSecond())); } } } // whatever remains in the tab are non matching left rows. if (leftType == JoinType.OUTER) { for (Map.Entry<K, T1> row : tab.entries()) { res.add(new Tuple3<>(row.getKey(), row.getValue(), null)); } } return res; }
From source file:eu.esdihumboldt.hale.common.core.service.cleanup.impl.CleanupServiceImpl.java
private <T> Collection<T> take(CleanupContext context, Multimap<CleanupContext, T> elements) { switch (context) { case APPLICATION: // all elements Collection<T> res1 = new ArrayList<T>(elements.values()); elements.clear();/* w w w . j av a 2 s . c o m*/ return res1; default: Collection<T> res2 = new ArrayList<T>(elements.get(context)); elements.removeAll(context); return res2; } }
From source file:com.google.gerrit.httpd.rpc.GerritJsonServlet.java
private Multimap<String, ?> extractParams(final Audit note, final GerritCall call) { Multimap<String, Object> args = ArrayListMultimap.create(); Object[] params = call.getParams(); for (int i = 0; i < params.length; i++) { args.put("$" + i, params[i]); }/* w ww .j a v a 2s. co m*/ for (int idx : note.obfuscate()) { args.removeAll("$" + idx); args.put("$" + idx, "*****"); } return args; }