Customer IEnuramble Extension
public static class IEnurambleExtension
{
public static IEnumerable<TSource> DistinctBy<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> keys = new HashSet<TKey>(); foreach (TSource element in source)
if (keys.Add(keySelector(element)))
yield return element;
} public static IEnumerable<int> DistinctByReturnIndexes<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> keys = new HashSet<TKey>();
int i = ;
foreach (TSource element in source)
{
if (!keys.Add(keySelector(element)))
yield return i;
i++;
}
} public static int FirstContainsWithIndex<TSource>
(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
int i = ;
foreach (TSource element in source)
{
if (predicate(element))
return i;
i++;
} return -;
} public static IEnumerable<int> ContainsReturnIndexes<TSource>
(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
int i = ;
foreach (TSource element in source)
{
if (predicate(element))
yield return i;
i++;
}
} public static void Print<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
foreach (TSource element in source)
Console.WriteLine(keySelector(element));
}
}
Customer IEnuramble Extension的更多相关文章
- Extension Method[下篇]
四.Extension Method的本质 通过上面一节的介绍,我们知道了在C#中如何去定义一个Extension Method:它是定义在一个Static class中的.第一个Parameter标 ...
- SAP Hybris Commerce启用customer coupon的前提条件
今天在工作中,我发现一个问题:在SAP帮助文档里,backoffice coupon 维护界面有个 Customer Assignment的区域: 而我工作的Hybris服务器上的backoffice ...
- 如何把SAP Kyma和SAP Cloud for Customer连接起来
首先进入SAP Cloud for Customer的Administration的工作中心,打开General Settings视图,进入Event Notification配置UI: 新建一个C4 ...
- EFCore之SQL扩展组件BeetleX.EFCore.Extension
EFCore是.NETCore团队开发的一个ORM组件,但这个组件在执行传统SQL的时候并不方便,因此BeetleX.EFCore.Extension的设计目的是让EFCore执行传 ...
- Windbg Extension NetExt 使用指南 【2】 ---- NetExt 的基本命令介绍
摘要 : 本章节介绍NetExt常用的命令. 并且对SOS进行一些对比. NetExt的帮助 要想玩好NetExt, 入门就得看帮助. 看NetExt的帮助可以调用!whelp 命令. 这样hi列举出 ...
- Windbg Extension NetExt 使用指南 【1】 ---- NetExt 介绍
摘要 : 在使用WINDBG做debugging的时候,需要一个好的工具帮助进行数据分析. 最常见的extension包括SOS, PSSCOR. NetExt则是另外一种提供了丰富命令功能的deb ...
- 「译」JUnit 5 系列:扩展模型(Extension Model)
原文地址:http://blog.codefx.org/design/architecture/junit-5-extension-model/ 原文日期:11, Apr, 2016 译文首发:Lin ...
- PHPmailer关于Extension missing: openssl报错的解决
最近在写一个网页的时候,需要用到PHPmailer来发送邮件,按照官网上给出的demo写出一个例子,却报错Extension missing: openssl 最后发现需要修改php.ini中的配置: ...
- 研究Extension和Category的一个例子
Category: 1. 无法添加实例变量 2.将类的实现分散到多个不同文件或多个不同框架中. Extension: 1. 可以添加实例变量 注: 如果Category的头文件中也使用Extensio ...
随机推荐
- hdu 5100 n*n棋盘放k*1长方条最多覆盖面积
http://acm.hdu.edu.cn/showproblem.php?pid=5100 给一个n*n的棋盘,问用k*1的长方条最多能覆盖多大的面积(k个单位都必须完全覆盖上去) 首先,若n< ...
- 使用的组件:Jcrop
JcropImage cropping for jQuery Jcrop 是一个功能强大的 jQuery 图像裁剪插件,结合后端程序(例如:PHP)可以快速的实现图片裁剪的功能. 官网地址:http: ...
- LDO-XC6216C202MR-G
XC6216C202MR-G 1.改产品是特瑞士(TOREX)公司电源管理芯片,输入电压可达28V,输出可调23V,最大输出电流150mA.压差最小为300mV.该系列有固定式输出和可调式 ...
- JAVA学习博客----2015.4
这是开始写的第一篇学习博客,记录一下每个月的学习进度和掌握程度,因为这是第一次写学习博客而且已经看编程方面的书已经有几个月了,所以这一篇学习博客可能看似有些乱或者篇幅太长.从十二月的<程序员教程 ...
- 如何使不同主机上的docker容器互相通信
docker启动时,会在宿主主机上创建一个名为docker0的虚拟网络接口,默认选择172.17.42.1/16,一个16位的子网掩码给容器提供了65534个IP地址.docker0只是一个在绑定到这 ...
- Twisted网络编程入门
Twisted是用Python实现的基于事件驱动的网络引擎框架,功能非常丰富,基本包括了常用的网络组件. 所谓事件驱动,就是说程序就像是一个报警器(reactor),时刻等待着外部事件(event), ...
- [ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]
Description Have you played Draw Something? It's currently one of the hottest social drawing games o ...
- [JS] HTML QQ分享界面js代码
@ - @ :可以自己指定分享内容等....内含JS脚本 <html> <head> <title></title> <script type=& ...
- How to use kingshard building a MySQL cluster
How to use kingshard building a MySQL cluster https://github.com/flike/kingshard/blob/master/doc/Kin ...
- 更新日志 - BugHD 全面开放 API 文档
Hey, 上周 BugHD 全面更新 API 文档,上线一些新的功能,让你可以轻松掌控 Crash ,更方便分享.定位和解决.同时,新版 fir.im 也有所优化,希望你们会喜欢. 具体如下: 开放 ...