收集按上次访问的对象排序 [英] Collection sorted on last accessed object

查看:93
本文介绍了收集按上次访问的对象排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


.NET是否提供任何最终给我对象的集合类

*访问*以便我可以构建最少的最近使用的缓存

杀掉了一段时间没用过的对象?


或者还有其他方法来实现这种类型的cache /

集合哪里可以基于

最近最少使用的对象进行这种清理?


Java有一个名为LinkedHashSet的集合类,它可以实现一个

。在.NET中是否有类似的东西 - 或其他一些方式

这样做?


任何指针都会非常感激。

非常感谢


问候


Vani

解决方案

在访问时将它移到前面并杀死后面的那些。任何允许移动和杀戮的

集合类都可以做到这一点,比如

ArrayList。


Vani Murarka ; < VA ********** @ gmail.com>在消息中写道

新闻:96 ************************* @ posting.google.co m ... < blockquote class =post_quotes>大家好,

.NET提供的任何集合类都会给我最后的对象*访问*以便我可以构建一个最近最少使用的缓存那个
会杀掉一段时间没用过的物品吗?

或者还有其他方法可以实现这种缓存/
集合,可以做到这一点基于最近最少使用的对象的清理方式?

Java有一个名为LinkedHashSet的集合类,它可以让人们做到这一点。在.NET中是否有类似的东西 - 或者其他一些方法呢?

任何指针都会非常感激。

非常感谢

问候

Vani



at写道:

只需将它移到前面在访问和杀死后面的人。任何允许移动和kill的
集合类都可以做到这一点,比如
ArrayList。




你可能会遇到性能问题,除了附加内容之外,ArrayList确实不会执行




你可以考虑使用splay-tree数据结构,它适合你的

要求非常好,而且非常容易实现。


-

Helge Jensen

mailto:他********** @ slog.dk

sip:他********** @ slog.dk

- =>塞巴斯蒂安的封面音乐: http://ungdomshus.nu < = -


我感兴趣并且让我感到惊讶,我没有测量ArrayList'的
表现为移动元素,但你能提供一些链接到

确认你的陈述?我并不反对你的陈述,但我想

一些确认。


然后,一个ArrayList标准意味着更少的代码写入和只要

它的表现还可以,为什么不坚持下去呢?可以随时根据需要将另一个容器更改为另外一个容器,然后让流程自动启动并先运行
然后查看性能是什么。


" Helge Jensen" <他********** @ slog.dk>在消息中写道

news:eu ************** @ TK2MSFTNGP14.phx.gbl ...

at写道:

只需在访问时将其移到前面并杀死后面的那些。允许移动和杀死的任何
集合类都可以做到这一点,比如
ArrayList。



你可能会遇到性能问题,ArrayList确实没有除了追加之外什么都不做。

你可以考虑使用splay-tree数据结构,它非常适合你的要求,而且非常容易实施。

-
Helge Jensen
mailto:他********** @ slog.dk
sip:他**** ******@slog.dk
- =>塞巴斯蒂安的封面音乐: http://ungdomshus.nu < = -



Hi Everyone,

Does .NET offer any collection class which will give me objects last
*accessed* such that I may build a least-recently-used cache that
kills off objects that haven''t been used for awhile?

Or is there any other way to implement this kind of a cache /
collection where one can do this kind of cleanup based on
least-recently-used objects?

Java has a collection class called LinkedHashSet which enables one to
do this. Is there something similar in .NET - or some other way of
doing this?

Any pointers will be really appreciated.

Thanks a ton

Regards

Vani

解决方案

Just move it to the front on access and kill those at the back. Any
collection class that allows the move and the kill will do for this, like
ArrayList.

"Vani Murarka" <va**********@gmail.com> wrote in message
news:96*************************@posting.google.co m...

Hi Everyone,

Does .NET offer any collection class which will give me objects last
*accessed* such that I may build a least-recently-used cache that
kills off objects that haven''t been used for awhile?

Or is there any other way to implement this kind of a cache /
collection where one can do this kind of cleanup based on
least-recently-used objects?

Java has a collection class called LinkedHashSet which enables one to
do this. Is there something similar in .NET - or some other way of
doing this?

Any pointers will be really appreciated.

Thanks a ton

Regards

Vani



at wrote:

Just move it to the front on access and kill those at the back. Any
collection class that allows the move and the kill will do for this, like
ArrayList.



You may run into performance-problems, ArrayList really doesn''t perform
that well on anything but appending.

You could look into using a splay-tree data-structure, it fits your
requirements pretty nice and is really easy to implement.

--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-


That interests and surprises me, I have not measured the ArrayList''s
performance for moving elements around but could you provide some links to
confirm your statement? I do not contradict your statement but I would like
some confirmation.

Then, an ArrayList comes standard meaning less code to write and as long as
its performance is ok why not stick with it? One can always change to
another container as the need arises and have the process itself up and
running first and then see what the performance is.

"Helge Jensen" <he**********@slog.dk> wrote in message
news:eu**************@TK2MSFTNGP14.phx.gbl...

at wrote:

Just move it to the front on access and kill those at the back. Any
collection class that allows the move and the kill will do for this, like
ArrayList.



You may run into performance-problems, ArrayList really doesn''t perform
that well on anything but appending.

You could look into using a splay-tree data-structure, it fits your
requirements pretty nice and is really easy to implement.

--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-



这篇关于收集按上次访问的对象排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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