本文整理汇总了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();
}