本文整理匯總了Java中java.util.HashSet.forEach方法的典型用法代碼示例。如果您正苦於以下問題:Java HashSet.forEach方法的具體用法?Java HashSet.forEach怎麽用?Java HashSet.forEach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.HashSet
的用法示例。
在下文中一共展示了HashSet.forEach方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeTasksAndAwaitDone
import java.util.HashSet; //導入方法依賴的package包/類
public boolean executeTasksAndAwaitDone(
PriorityTaskQueue taskQueue,
ExecutorService executorService,
Consumer<Exception> exceptionListener,
Object input,
Consumer<O> onResult,
long timeout,
TimeUnit unit) {
if (!children.isEmpty()) {
throw new RuntimeException("This step has children; please start executing at the tail of the graph");
}
this.onResult = onResult;
// walk the step graph: configure the graph depth on each step and find the root steps
HashSet<Step<Object, ?>> roots = new HashSet<>();
configureTreeAndFindRoots(new HashSet<>(), roots);
// start execution by scheduling tasks for all roots
roots.forEach(rootStep -> rootStep.post(input, taskQueue));
return taskQueue.executeTasksAndAwaitDone(executorService, exceptionListener, timeout, unit);
}
示例2: onMessage
import java.util.HashSet; //導入方法依賴的package包/類
@Override
public void onMessage(String channel, String message)
{
try
{
HashSet<IPacketsReceiver> receivers = packetsReceivers.get(channel);
if (receivers != null)
receivers.forEach((IPacketsReceiver receiver) -> receiver.receive(channel, message));
else
APIPlugin.log(Level.WARNING, "{PubSub} Received message on a channel, but no packetsReceivers were found. (channel: " + channel + ", message:" + message + ")");
APIPlugin.getInstance().getDebugListener().receive("onlychannel", channel, message);
} catch (Exception ignored)
{
ignored.printStackTrace();
}
}
示例3: onPMessage
import java.util.HashSet; //導入方法依賴的package包/類
@Override
public void onPMessage(String pattern, String channel, String message)
{
try
{
HashSet<IPatternReceiver> receivers = patternsReceivers.get(pattern);
if (receivers != null)
receivers.forEach((IPatternReceiver receiver) -> receiver.receive(pattern, channel, message));
else
APIPlugin.log(Level.WARNING, "{PubSub} Received pmessage on a channel, but no packetsReceivers were found.");
APIPlugin.getInstance().getDebugListener().receive(pattern, channel, message);
} catch (Exception ignored)
{
ignored.printStackTrace();
}
}
示例4: allAdminUsers
import java.util.HashSet; //導入方法依賴的package包/類
@Cacheable(CsapCoreService.TIMEOUT_CACHE_60s)
synchronized public ArrayNode allAdminUsers () {
ArrayNode users = jacksonMapper.createArrayNode() ;
// remove calls for other hosts
csapApp.getAllPackages()
.getServiceInstances( "admin" )
.filter( instance -> ! instance.getHostName().equals( Application.getHOST_NAME() ) )
.map( this::getUsersOnRemoteAdmins )
.forEach( users::addAll );
// add the local host entries
users.addAll( getActive() ) ;
// now make them distinct
HashSet<String> uniqueUsers = new HashSet<>() ;
users.forEach( userJson -> uniqueUsers.add( userJson.asText() ));
// Now transform
users.removeAll() ;
uniqueUsers.forEach( users::add );
return users ;
}
示例5: onMessage
import java.util.HashSet; //導入方法依賴的package包/類
@Override
public void onMessage(String channel, String message)
{
HashSet<PacketReceiver> receivers = this.packetsReceivers.get(channel);
if (receivers != null)
receivers.forEach((PacketReceiver receiver) -> receiver.receive(message));
}
示例6: execute
import java.util.HashSet; //導入方法依賴的package包/類
public void execute(Map<String, Group> ocpGroups, Map<String, Group> ldapGroups) {
HashSet<String> syncGroups = createSynchronizationSelector(ocpGroups, ldapGroups);
HashSet<String> deletionGroups = createSelector(ldapGroups, ocpGroups);
HashSet<String> creationGroups = createSelector(ocpGroups, ldapGroups);
HashSet<Action<Group>> actions = new HashSet<>();
actions.addAll(prepareDeletionGroups(ocpGroups, deletionGroups));
actions.addAll(prepareSyncGroups(ocpGroups, ldapGroups, syncGroups));
actions.addAll(prepareCreationGroups(ldapGroups, creationGroups));
actions.forEach(Action::execute);
}
示例7: toDotFile
import java.util.HashSet; //導入方法依賴的package包/類
/**
* Creates a DOT file from this NetworkGraph object.
* This can be used to quickly draw the graph with graphviz methods.
*
* @return DOT file containing the graph.
*/
public String toDotFile() {
HashSet<Link> links = getLinks();
StringBuilder sb = new StringBuilder("graph networkGraphTest {\n" +
" node [\n" +
" shape = \"circle\",\n" +
" style = \"filled\",\n" +
" fontsize = 16,\n" +
" fixedsize = true\n" +
" ];\n" +
"\n" +
" edge [\n" +
" color = \"#bbbbbb\"\n" +
" ];\n" +
"\n" +
" // nodes with CPU\n" +
" node [\n" +
" color = \"#007399\",\n" +
" fillcolor = \"#007399\",\n" +
" fontcolor = white\n" +
" ];\n");
// Nodes with CPU resources:
nodes.values().stream().filter(n -> n.cpuCapacity > 0.0).forEach(n -> sb.append(" ").append(n.name).append(";\n"));
sb.append("\n" +
" // nodes without CPU\n" +
" node [\n" +
" color = \"#4dd2ff\",\n" +
" fillcolor = \"#4dd2ff\",\n" +
" fontcolor = black\n" +
" ];\n");
// Nodes without CPU resources:
nodes.values().stream().filter(n -> n.cpuCapacity == 0.0).forEach(n -> sb.append(" ").append(n.name).append(";\n"));
sb.append("\n" +
" // edges\n");
// Edges:
links.forEach(l -> sb.append(" ")
.append(l.node1.name)
.append(" -- ")
.append(l.node2.name)
.append(" [ label = \"")
.append(Math.round(l.delay))
.append("\" ];\n"));
sb.append("}");
return sb.toString();
}