惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
N
News and Events Feed by Topic
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
博客园 - 叶小钗
B
Blog
Vercel News
Vercel News
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
G
GRAHAM CLULEY
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
A
About on SuperTechFans
W
WeLiveSecurity
The GitHub Blog
The GitHub Blog

博客园 - GL_BKY

AI笔记 hippo4j线程池监控落地 Redisson实现分布式限流 Archery SQL 审核查询平台 mybatis-typeHandler解决表字段中json映射对象问题 WebLogAspect 面试常问题 自动代码质量分析示例搭建 Springboot监听多个端口 Git使用规范 一些问题 netty MQ Spring dubbo+zookeeper JVM 数据结构 redis JS前端加密JAVA后端解密详解
ConcurrentSkipListMap实现随机数命中权重占比
GL_BKY · 2023-02-13 · via 博客园 - GL_BKY
public String getCoverBottom(FlowAdditions additions) {
        if(null==additions){
            return "默认";
        }
        List<FlowCoverBottom> li = this.isMatchBottom(additions);
        if(null == li || li.isEmpty()){
            return "默认";
        }
        //根据权重输出兜底方。
        int sum = li.stream().mapToInt(FlowCoverBottom::getIntRatio).sum();
        int random = RandomUtils.nextInt(0, sum);
        ConcurrentSkipListMap<Integer,String> skipListMap = new ConcurrentSkipListMap<>();
        int ceiling = 0;
        for(int i=0;i<li.size();i++){
            FlowCoverBottom bottom = li.get(i);
            ceiling = ceiling+bottom.getIntRatio();
            skipListMap.put(ceiling,bottom.getCode());
        }
        return skipListMap.higherEntry(random).getValue();
    }

posted @ 2023-02-13 17:11  GL_BKY  阅读(49)  评论()    收藏  举报