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

推荐订阅源

P
Palo Alto Networks Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
量子位
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
腾讯CDC
博客园 - Franky
The Cloudflare Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hugging Face - Blog
Hugging Face - Blog
H
Heimdal Security Blog
L
LangChain Blog
V
V2EX
Jina AI
Jina AI
美团技术团队
V2EX - 技术
V2EX - 技术
V
Visual Studio Blog
Google Online Security Blog
Google Online Security Blog
人人都是产品经理
人人都是产品经理
Security Archives - TechRepublic
Security Archives - TechRepublic
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Know Your Adversary
Know Your Adversary
Hacker News: Ask HN
Hacker News: Ask HN
Apple Machine Learning Research
Apple Machine Learning Research
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
C
Cisco Blogs
博客园 - 三生石上(FineUI控件)
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
PCI Perspectives
PCI Perspectives
MongoDB | Blog
MongoDB | Blog
A
About on SuperTechFans
B
Blog RSS Feed
N
News and Events Feed by Topic
L
LINUX DO - 热门话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threatpost
月光博客
月光博客
Recent Announcements
Recent Announcements
D
DataBreaches.Net
IT之家
IT之家
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - cjfwu

设计模式学习4-Bridge模式 设计模式学习3-Strategy模式 设计模式学习2-Adapter模式 设计模式学习1-Facade模式 设备控制(反馈处理) 通过System.IO.Packaging实现打包和解包 将目录添加环境变量 设备控制之矩阵状态显示 windows shell 编程3(函数解释) windows shell 编程2(浏览文件夹) windows shell 编程1(概念) 不同命名空间下名称和结构相同的类相互序列化与反序列化 通过SvcUtil.exe生成客户端代码和配置 在“添加引用”对话框中显示需要的Assembly 只运行一个实例 SVN操作 托盘操作 获得树节点的高度 枚举的操作
分组
cjfwu · 2008-12-05 · via 博客园 - cjfwu

    class GroupTest {
        static void Main(string[] args) {
            List<int> src = new List<int> { 1, 5, 11, 22, 4, 3 };

            List<List<int>> gs = Split<int>(src, (current, next) => { return (current < 10 && next < 10); });
            //List<List<int>> gs = Split<int>(src, (current, next) => { return (current < 10 && next < 10) || (current >= 10 && next >= 10); });

            foreach (var each in gs) {
                List<string> t = new List<string>();
                each.ForEach(e => t.Add(e.ToString()));
                Console.WriteLine(string.Join(" ", t.ToArray()));
            }

            Console.WriteLine("== End ==");
            Console.ReadKey();
        }

        private static List<List<T>> Split<T>(List<T> src, Condition<T> condition) {
            List<List<T>> result = new List<List<T>>();

            List<T> current = new List<T>();
            for (int i = 0; i < src.Count; ++i) {
                T cur = src[i];
                T next = default(T);
                if (i < src.Count - 1) { next = src[i + 1]; }

                current.Add(cur);
                if (src.Count == i + 1 || !condition(cur, next)) {
                    result.Add(current);
                    current = new List<T>();
                }
            }

            return result;
        }
    }

    delegate bool Condition<T>(T current, T next);