VB6 中的集合是怎样实现的?

发布于 2024-08-27 07:55:16 字数 140 浏览 5 评论 0原文

因此,VB6 中的集合会跟踪每个对象的键,您可以通过其键查找该对象。

这是否意味着集合在底层被实现为某种哈希表?我意识到你可以在一个集合中拥有多个具有相同键的项目,因此是某种排序。

有人知道 VB6 集合应该代表什么类型的数据结构吗?

So a collection in VB6 keeps track of a key for each object, and you can look up the object by its key.

Does that mean collections are implemented as some sort of hashtable under the hood? I realize you can have multiple items with the same key in a collection, hence the SOME SORT.

Anybody know what type data structure a VB6 collection is supposed to represent?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2024-09-03 07:55:16

据我所知,VBA Collection 是作为链表(由 Integer 索引和 For Each...Next 使用)和哈希表(由键使用)实现的。正如 Raven 所说,你不能拥有多个具有相同密钥的项目。


来源:

Hardcore Visual Basic 第二版。作者:Bruce McKinney,由 Microsoft Press 出版 1997 ISBN 1-57231-422-2

引用:

第 191 页 - 集合类

“简单地说,Collection 类是一个增强的 C++ 版本
CList 类 [...]。事实上,如果你将 CList 增强为双重的
链表并给它更多的功能(也许使用散列
表来查找字符串键),你将有一个集合类
就像 Visual Basic 提供的那样。”

第 197 页 - 性能

“事实上,Visual Basic 开发人员告诉我
集合是双向链表(具有附加功能
支持索引)。”

在 Microsoft 工作,并且在 VB 和 VBA 团队中有联系。他的解释对我有用。

顺便说一下,原因是双向链表的目的是为了提高在集合的开头和结尾插入项目的效率。

As far as I know, the VBA Collection is implemented as a linked list (used by Integer indexes and For Each...Next) and a hash table (used by keys). And as Raven said, you can't have multiple items with the same key.


Sources:

Hardcore Visual Basic 2nd Ed. by Bruce McKinney, published by Microsoft Press 1997 ISBN 1-57231-422-2

Quotes:

Page 191 - The Collection Class

"To put it simply, the Collection class is a souped-up C++ version of
the CList class [...]. In fact, if you enhance CList to be a doubly
linked list and give it a few more features (and perhaps use a hash
table to look up string keys), you'll have a collection class much
like the one provided with Visual Basic."

Page 197 - Performance

"And, as a matter of fact, I have been told by Visual Basic developers
that Collections are doubly linked lists (with additional features to
support indexing)."

Now, McKinney was more of a journalist than a programmer, and not a developer. However, he did work for Microsoft, and have contacts in the VB and VBA teams. His explanation works for me.

Incidentally, the reason for the doubly-linked list is to make it efficient to insert items at both the beginning and end of the collection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文