随笔 - 850  文章 - 37  评论 - 173  阅读 - 287万
12 2017 档案
树状结构 Tree data structure in C#
摘要:delegate void TreeVisitor(T nodeData); class NTree { private T data; private LinkedList> children; public NTree(T data) { this.data = data; children = new LinkedLis... 阅读全文
posted @ 2017-12-20 17:24 武胜-阿伟 阅读(433) 评论(0) 推荐(0) 编辑
wrap ConcurrentDictionary in BlockingCollection
摘要:ConcurrentDictionary> mailBoxes = new ConcurrentDictionary>(); int maxBoxes = 5; CancellationTokenSource cancelationTokenSource = new CancellationTokenSource(); CancellationT... 阅读全文
posted @ 2017-12-15 15:39 武胜-阿伟 阅读(336) 评论(0) 推荐(0) 编辑
ConcurrentBag扩展 批量加入
摘要:public static void AddRange(this ConcurrentBag @this, IEnumerable toAdd) { foreach (var element in toAdd) { @this.Add(element); } } 阅读全文
posted @ 2017-12-15 15:34 武胜-阿伟 阅读(873) 评论(1) 推荐(1) 编辑
Dictionary GetOrAdd
摘要:public static TValue GetOrAdd( this Dictionary dictionary, TKey key, Func valueFactory) { TValue value; if (!dictionary.TryGetValue(key, out value)) { value = valueFactory(ke... 阅读全文
posted @ 2017-12-15 15:31 武胜-阿伟 阅读(857) 评论(0) 推荐(0) 编辑
ConcurrentDictionary AddOrUpdate
摘要:var sessionId = a.Session.SessionID.ToString(); userDic.AddOrUpdate( authUser.UserId, sessionId, (key, oldValue) => sessionId); static class Extension 阅读全文
posted @ 2017-12-15 15:26 武胜-阿伟 阅读(6819) 评论(0) 推荐(0) 编辑
object pool
摘要:/// /// 对象池 /// /// public class ObjectPool { private readonly ConcurrentBag _buffer; private readonly Func _createFunc; private readonly Action _reset... 阅读全文
posted @ 2017-12-15 11:29 武胜-阿伟 阅读(206) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示