当前位置: 首页>>代码示例>>Java>>正文


Java HashSet.forEach方法代码示例

本文整理汇总了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);
}
 
开发者ID:systek,项目名称:dataflow,代码行数:24,代码来源:Step.java

示例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();
    }

}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:19,代码来源:Subscriber.java

示例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();
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:18,代码来源:Subscriber.java

示例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 ;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:28,代码来源:ActiveUsers.java

示例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));
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:9,代码来源:RedisSubscriber.java

示例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);
    }
 
开发者ID:klenkes74,项目名称:openshift-ldapsync,代码行数:14,代码来源:SyncGroupExecutor.java

示例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();
}
 
开发者ID:lsinfo3,项目名称:mo-vnfcp,代码行数:58,代码来源:NetworkGraph.java


注:本文中的java.util.HashSet.forEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。