以相反的顺序迭代hashtabel [英] Iterate over hashtabel in reverse order

查看:83
本文介绍了以相反的顺序迭代hashtabel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


代码通过哈希表迭代。

Dim _Enumerator IDictionaryEnumerator = _myhashtable.GetEnumerator


虽然_Enumerator.MoveNext()


....


结束时


但是我找不到一种反向迭代的方法。类似......


Dim _Enumerator作为IDictionaryEnumerator = _myhashtable.GetReverseEnumerator


虽然_Enumerator.MovePrevious()

....


结束时


有可能吗?


谢谢

Dear all,

following code iterates thru the hash table.

Dim _Enumerator As IDictionaryEnumerator = _myhashtable.GetEnumerator

While _Enumerator.MoveNext()

....

End While

But I can''t find a way to iterate in reverse direction. Something like...

Dim _Enumerator As IDictionaryEnumerator = _myhashtable.GetReverseEnumerator

While _Enumerator.MovePrevious()

....

End While

It is possible?

Thanks

推荐答案

只是一个补充。我希望有可能有答案说,哈希表是

不是一个正确的集合。什么是正确的?我需要输入/获得

值/键(带密钥检查)。我需要能够在
方向上进行迭代。

谢谢,

Boni
Just an addtion. I expect there could be answers saying, that hashtable is
not a right collection for that. What is a right one? I need to put/get
value/key (with key check). And I need to be able to iterate in both
directions.
Thanks,
Boni

如何创建自己继承自Hashtable的类?给它一个

公共属性,比如InterationDirection,然后实现你自己的

枚举器,检查属性并将光标移动到

适当的方向。请参阅IEnumerable和Enumerator上的帮助文件

了解如何实现自己的。


Tom Dacon

Dacon Software Consulting


" Boni" < oilia @ NOSPAM>在消息中写道

news:uw ************** @ TK2MSFTNGP10.phx.gbl ...
How about creating your own class that inherits from Hashtable? Give it a
public property like InterationDirection, and then implement your own
enumerator that inspects the property and moves its cursor in the
appropriate direction. See the help file on IEnumerable and Enumerator to
see how to implement your own.

Tom Dacon
Dacon Software Consulting

"Boni" <oilia@nospam> wrote in message
news:uw**************@TK2MSFTNGP10.phx.gbl...
亲爱的所有人,
Dim _Enumerator As IDictionaryEnumerator = _myhashtable.GetEnumerator

而_Enumerator.MoveNext()


结束时

但我无法找到一种反向迭代的方法。有点像......

Dim _Enumerator作为IDictionaryEnumerator =
_myhashtable.GetReverseEnumerator

而_Enumerator.MovePrevious()

...

结束时

有可能吗?

Dear all,

following code iterates thru the hash table.

Dim _Enumerator As IDictionaryEnumerator = _myhashtable.GetEnumerator

While _Enumerator.MoveNext()

...

End While

But I can''t find a way to iterate in reverse direction. Something like...

Dim _Enumerator As IDictionaryEnumerator =
_myhashtable.GetReverseEnumerator

While _Enumerator.MovePrevious()

...

End While

It is possible?

Thanks


亲爱的汤姆,

你知道如何在哈希表上以相反的方向移动光标吗?它正是我正在寻找的,而且无法弄明白。
Dear Tom,
Do you know how to move cursor in oposite direction on hashtable? It is
exactly what I am looking for and can''t figure out.


这篇关于以相反的顺序迭代hashtabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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