要使用哪个Collection类 [英] Which Collection class to use

查看:58
本文介绍了要使用哪个Collection类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个NT服务来提供企业范围内的安全信息。如果先前的请求将其加载到内存中,我想将所有这些信息缓存

内存。然后使用通用界面,我可以在更新时取消和卸载旧的

信息(从集合中删除项目?)


我的大问题是什么样的集合类会给我最大的灵活性和最好的表现?


我希望这很清楚...我真的不知道怎么形容我是什么试着说。

解决方案

恕我直言,哈希表是一个不错的选择。我不确定你打算存储什么样的

信息,但我认为这将是一些对象

最有可能带有一些唯一标识符。您可以将信息添加到

哈希表中:


dim oHash as New Hashtable

o.Add(ID,mySecurityObject )


然后,当你需要再次访问它时(或者因为你想要更新信息或删除陈旧信息)你可以做类似的事情:


如果o.Contains(ID)那么

''这个......

o。移除(ID)

''或者这个..

o.Item(ID)= myUpdatedSecurityObject

结束如果


Contains方法允许您极快地搜索哈希表

结构中的现有对象。唯一的要求是所有的密钥(在这种情况下,

中的ID)必须是唯一的。


我希望这给你一个足够好的想法继续。 。

Imran。

" Scott Meddows" < SC ****************** @ tsged-removeme.com>在消息中写道

新闻:eN ************* @ TK2MSFTNGP10.phx.gbl ...

我正在写一篇NT服务为企业提供安全信息。
如果先前的请求将其加载到内存中,我希望将所有这些信息缓存到内存中。然后使用一个常见的
界面,我可以在更新时将旧信息无效和卸载(从集合中删除项目?)

我的重要问题是集合类会给我什么最大的
灵活性和最佳性能?
我希望这很明确......我真的不知道如何描述我想要说的话。



是的,这有帮助。但是我们在讨论什么样的内存需求呢?


我基本上会在内存中保留一个对象层次结构


" Imran Koradia <无**** @ microsoft.com>在留言新闻中写道:%2 **************** @ TK2MSFTNGP15.phx.gbl ...

恕我直言,哈希表是一个不错的选择。我不确定你打算存储什么样的信息,但我认为这可能是某些对象
最有可能带有一些独特的标识符。您可以将信息添加到
哈希表中:

dim oHash as New Hashtable
o.Add(ID,mySecurityObject)

然后,当你需要再次访问它(要么是因为你想要更新信息或删除陈旧的信息)你可以做类似的事情:

如果o.Contains(ID)那么
''或者这个......
o。移动(ID)
''或者这个..
o.Item(ID)= myUpdatedSecurityObject
结束如果

Contains方法允许您非常快速地搜索哈希表结构中的现有对象。唯一的要求是所有的钥匙(这种情况下的ID)必须是唯一的。

我希望这能给你一个足够好的想法继续......
Imran。

" Scott Meddows" < SC ****************** @ tsged-removeme.com>在消息中写道
新闻:eN ************* @ TK2MSFTNGP10.phx.gbl ...

我正在写一个NT服务来提供企业范围内的安全信息。


如果先前的请求将其加载到内存中,我希望将所有这些信息缓存到

内存中。然后使用一个通用的


接口,我可以在更新时删除旧的

信息(从集合中删除项目?)


灵活性和最佳性能?


我希望这很明确......我真的不喜欢我不知道如何描述我


试图说出来。




另外,我会从这个类继承还是创建一个新的哈希表,然后将我的对象推到那里?


" Imran Koradia" <无**** @ microsoft.com>在留言新闻中写道:%2 **************** @ TK2MSFTNGP15.phx.gbl ...

恕我直言,哈希表是一个不错的选择。我不确定你打算存储什么样的信息,但我认为这可能是某些对象
最有可能带有一些独特的标识符。您可以将信息添加到
哈希表中:

dim oHash as New Hashtable
o.Add(ID,mySecurityObject)

然后,当你需要再次访问它(要么是因为你想要更新信息或删除陈旧的信息)你可以做类似的事情:

如果o.Contains(ID)那么
''或者这个......
o。移动(ID)
''或者这个..
o.Item(ID)= myUpdatedSecurityObject
结束如果

Contains方法允许您非常快速地搜索哈希表结构中的现有对象。唯一的要求是所有的钥匙(这种情况下的ID)必须是唯一的。

我希望这能给你一个足够好的想法继续......
Imran。

" Scott Meddows" < SC ****************** @ tsged-removeme.com>在消息中写道
新闻:eN ************* @ TK2MSFTNGP10.phx.gbl ...

我正在写一个NT服务来提供企业范围内的安全信息。


如果先前的请求将其加载到内存中,我希望将所有这些信息缓存到

内存中。然后使用一个通用的


接口,我可以在更新时删除旧的

信息(从集合中删除项目?)


灵活性和最佳性能?


我希望这很明确......我真的不喜欢我不知道如何描述我


试图说出来。




I''m writing an NT service to provide security information enterprise wide. I would like to have all of this information cached
memory if a previous request loaded it into memory. Then using a common interface I would be able to invalidate and unload old
information as it is updated (Removing the item from the collection?)

My big question is what collection class will give me the greatest flexibility and greatest performance?

I hope this is clear... I really don''t know how to describe what I''m trying to say.

解决方案

IMHO, a hashtable would be a good choice. I''m not sure what kind of
information you are planning to store but I assume it would be some object
most likely with some unique identifier. You can add the information to the
hashtable as:

dim oHash as New Hashtable
o.Add(ID, mySecurityObject)

Then, when you need to access it again (either because you want to update
the information or remove the stale information) you can do something like:

if o.Contains(ID) then
''either this...
o.Remove(ID)
''or this..
o.Item(ID) = myUpdatedSecurityObject
end if

The Contains method lets you search for an existing object in the hashtable
structure extremely fast. The only requirement is that all the keys (IDs in
this case) must be unique.

I hope that gives you a good enough idea to proceed..
Imran.
"Scott Meddows" <sc******************@tsged-removeme.com> wrote in message
news:eN*************@TK2MSFTNGP10.phx.gbl...

I''m writing an NT service to provide security information enterprise wide. I would like to have all of this information cached memory if a previous request loaded it into memory. Then using a common interface I would be able to invalidate and unload old information as it is updated (Removing the item from the collection?)

My big question is what collection class will give me the greatest flexibility and greatest performance?
I hope this is clear... I really don''t know how to describe what I''m trying to say.



Yeah, that helps. What kind of memory requirements are we talking about with this, though?

I will basically be keeping an object hierarchy in memory

"Imran Koradia" <no****@microsoft.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...

IMHO, a hashtable would be a good choice. I''m not sure what kind of
information you are planning to store but I assume it would be some object
most likely with some unique identifier. You can add the information to the
hashtable as:

dim oHash as New Hashtable
o.Add(ID, mySecurityObject)

Then, when you need to access it again (either because you want to update
the information or remove the stale information) you can do something like:

if o.Contains(ID) then
''either this...
o.Remove(ID)
''or this..
o.Item(ID) = myUpdatedSecurityObject
end if

The Contains method lets you search for an existing object in the hashtable
structure extremely fast. The only requirement is that all the keys (IDs in
this case) must be unique.

I hope that gives you a good enough idea to proceed..
Imran.
"Scott Meddows" <sc******************@tsged-removeme.com> wrote in message
news:eN*************@TK2MSFTNGP10.phx.gbl...

I''m writing an NT service to provide security information enterprise wide.


I would like to have all of this information cached

memory if a previous request loaded it into memory. Then using a common


interface I would be able to invalidate and unload old

information as it is updated (Removing the item from the collection?)

My big question is what collection class will give me the greatest


flexibility and greatest performance?


I hope this is clear... I really don''t know how to describe what I''m


trying to say.




Also, would I just inherit from this class or create a new hashtable and just shove my objects in there?

"Imran Koradia" <no****@microsoft.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...

IMHO, a hashtable would be a good choice. I''m not sure what kind of
information you are planning to store but I assume it would be some object
most likely with some unique identifier. You can add the information to the
hashtable as:

dim oHash as New Hashtable
o.Add(ID, mySecurityObject)

Then, when you need to access it again (either because you want to update
the information or remove the stale information) you can do something like:

if o.Contains(ID) then
''either this...
o.Remove(ID)
''or this..
o.Item(ID) = myUpdatedSecurityObject
end if

The Contains method lets you search for an existing object in the hashtable
structure extremely fast. The only requirement is that all the keys (IDs in
this case) must be unique.

I hope that gives you a good enough idea to proceed..
Imran.
"Scott Meddows" <sc******************@tsged-removeme.com> wrote in message
news:eN*************@TK2MSFTNGP10.phx.gbl...

I''m writing an NT service to provide security information enterprise wide.


I would like to have all of this information cached

memory if a previous request loaded it into memory. Then using a common


interface I would be able to invalidate and unload old

information as it is updated (Removing the item from the collection?)

My big question is what collection class will give me the greatest


flexibility and greatest performance?


I hope this is clear... I really don''t know how to describe what I''m


trying to say.




这篇关于要使用哪个Collection类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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