VB6 中的集合是怎样实现的?
因此,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,VBA Collection 是作为链表(由 Integer 索引和 For Each...Next 使用)和哈希表(由键使用)实现的。正如 Raven 所说,你不能拥有多个具有相同密钥的项目。
来源:
Hardcore Visual Basic 第二版。作者:Bruce McKinney,由 Microsoft Press 出版 1997 ISBN 1-57231-422-2
引用:
第 191 页 - 集合类
第 197 页 - 性能
在 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
Page 197 - Performance
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.