.Net中弱字典的良好实现 [英] Good implementation of weak dictionary in .Net

查看:128
本文介绍了.Net中弱字典的良好实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到使用弱引用的 IDictionary 的良好实现?



字典应该只保留或者我应该自己写?

解决方案

ConditionalWeakTable Class 使用弱键,一旦在表外没有其他对键的引用,就会自动删除键/值输入。


Where can I find good implementation of IDictionary which uses weak references inside?

Dictionary should be holding only weak references to values and eventually clean up itself of dead references.

Or should I just write it myself?

解决方案

ConditionalWeakTable Class uses weak keys and automatically removes the key/value entry as soon as no other references to a key exist outside the table.

这篇关于.Net中弱字典的良好实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆