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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LINUX DO - 最新话题
Recorded Future
Recorded Future
月光博客
月光博客
博客园 - 【当耐特】
博客园 - 叶小钗
宝玉的分享
宝玉的分享
量子位
雷峰网
雷峰网
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
Vercel News
Vercel News
L
LangChain Blog
B
Blog
Y
Y Combinator Blog
爱范儿
爱范儿
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
博客园 - Franky
P
Palo Alto Networks Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
Scott Helme
Scott Helme
I
Intezer
T
The Exploit Database - CXSecurity.com
MyScale Blog
MyScale Blog
T
Tor Project blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Troy Hunt's Blog
N
News and Events Feed by Topic
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Security Affairs
Cyberwarzone
Cyberwarzone
PCI Perspectives
PCI Perspectives
小众软件
小众软件
D
DataBreaches.Net
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Know Your Adversary
Know Your Adversary
Forbes - Security
Forbes - Security
S
Securelist
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
The Last Watchdog
The Last Watchdog

博客园 - yuejianjun

搜索结果点击情况 进行加权 java httpURL连接远程服务器并返回数据(httpurlconnection)(转) 实体类 topN topN 堆排序 (int 类型) 过滤词 Lucene的评分(score) 位运算包含功能 页面抓取匹配时,万恶的 , , 要先替换掉为空,出现匹配有问题,都是这个引起的 探索推荐引擎内部的秘密,第 1 部分: 推荐引擎初探 深度用户行为 多维度深入分析笔记 lucene 搜索学习笔记 - OK 中文自动摘要提取 常用的vs编码 快捷键 Lucene中的堆(Heap)[ScorerDocQueue,TopScoreDocCollector] lucene 大数据量 快速 排序 T a s k 搜 索 ( L u c e n e ) l u c e n e 创 建 修 改 删 除 索 引 集中、分布式搜索引擎的4种设计方案 lucene fenlei ThreadPool 使用
位图求交集
yuejianjun · 2012-04-26 · via 博客园 - yuejianjun

位图求交集

2012-04-26 23:00  yuejianjun  阅读(443)  评论()    收藏  举报

位图求交集 

 View Code

    

public class 位图求交集
    {
        /// <summary>
        
/// 排序数组
        
/// </summary>
        
/// <param name="list">排序数组</param>
        
/// <param name="MaxNumber"></param>
        
/// <returns></returns>
        public static List<int> BitList(List<List<int>> list)
        {
            int count=list.Count;
            int minInt = 0, maxInt = 0
            for (int i = 0; i < list.Count; i++)
            {
                minInt = minInt < list[i][0] ? minInt : list[i][0];
                maxInt = maxInt > list[i][list[i].Count - 1] ? maxInt : list[i][list[i].Count - 1]; 
            }
            List<int> result = new List<int>();
            int[] DataForStore = new int[maxInt+1];
            for (int i = 0; i < list.Count; i++)
            {
                for (int j = 0; j < list[i].Count; j++)
                {
                    DataForStore[list[i][j]]++;
                }
            }
            for (int m = minInt; m < DataForStore.Length; m++)
            {
                if (DataForStore[m] == count)
                {
                    result.Add(m);
                }
            }
            return result;
        }
        /// <summary>
        
/// 非排序数组
        
/// </summary>
        
/// <param name="list">非排序数组</param>
        
/// <param name="MaxNumber"></param>
        
/// <returns></returns>
        public static  List<int> BitList(List<List<int>> list, int MaxNumber)
        {
            List<int> result = new List<int>();
            int[] DataForStore = new int[MaxNumber];
            for (int i = 0; i < list.Count; i++)
            {
                for (int j = 0; j < list[i].Count; j++)
                {
                    DataForStore[list[i][j]]++;
                }
            }
            int length = list.Count;
            for (int m = 0; m < DataForStore.Length; m++)
            {
                if (DataForStore[m] == length)
                {
                    result.Add(m);
                }
            }
            return result;
        }

Test

View Code 

两个时间差不多,1000000 数据 非排序的性能还要略微好点,都是40-50毫秒左右,性能至于最大的值有关,与每个数组的长度没关系