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

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
Project Zero
Project Zero
K
Kaspersky official blog
G
Google Developers Blog
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Recorded Future
Recorded Future
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
Microsoft Security Blog
Microsoft Security Blog
H
Help Net Security
S
Schneier on Security
P
Palo Alto Networks Blog
H
Hacker News: Front Page
N
News and Events Feed by Topic
N
Netflix TechBlog - Medium
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
SecWiki News
SecWiki News
Cloudbric
Cloudbric
TaoSecurity Blog
TaoSecurity Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Hacker News
The Hacker News
C
Check Point Blog
L
LangChain Blog
腾讯CDC
小众软件
小众软件
T
Tenable Blog
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
About on SuperTechFans
Google Online Security Blog
Google Online Security Blog
C
Cisco Blogs
Recent Announcements
Recent Announcements
Hacker News: Ask HN
Hacker News: Ask HN
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Vercel News
Vercel News
雷峰网
雷峰网
美团技术团队
D
DataBreaches.Net
Martin Fowler
Martin Fowler
Help Net Security
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
博客园_首页

博客园 - 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)  评论()    收藏  举报