HashSet的是preserves订购 [英] HashSet that preserves ordering

查看:189
本文介绍了HashSet的是preserves订购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个HashSet的是preserves插入排序,还有这实现任何框架中的?

I need a HashSet that preserves insertion ordering, are there any implementations of this in the framework?

推荐答案

您可以用得到这个功能,很容易 KeyedCollection< TKEY的,TItem> 指定相同类型参数TKEY的和TItem:

You can get this functionality easily using KeyedCollection<TKey,TItem> specifying the same type argument for TKey and TItem:

public class OrderedHashSet<T> : KeyedCollection<T, T>
{
    protected override T GetKeyForItem(T item)
    {
        return item;
    }
}

这篇关于HashSet的是preserves订购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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