什么是实现集合在VB6? [英] What Are Collections Implemented As In VB6?

查看:123
本文介绍了什么是实现集合在VB6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



这意味着集合被实现为某种类型的hashtable在引擎盖下?我意识到你可以有一个集合中的同一个键的多个项目,因此SOME SORT。



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

解决方案

据我所知,VBA集合被实现为链表(由Integer索引和For Each ... Next使用)和哈希表(由键使用)。

b $ b

@MarkJ:我应该给出我的引用:
Hardcore Visual Basic 2nd Ed。作者:Bruce McKinney,由Microsoft Press出版1997 ISBN 1-57231-422-2



行情:



191 - 集合类



简单来说,Collection类是CList类[...]的C ++版本,事实上,如果你将CList增强为一个双向链表,并给它一些更多的功能(也许使用一个哈希表来查找字符串键),你将有一个集合类,类似于Visual Basic提供的类。





事实上,Visual Basic开发人员告诉我是双重链接的列表(具有支持索引的额外功能)。



现在,McKinney更像是一个记者而不是程序员,而不是开发人员。但是,他为微软工作,在VB和VBA团队有联系人。他的解释对我有用。



顺便说一下,双向链表的原因是让它在集合的开始和结尾都有效地插入项目。 / p>

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?

解决方案

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.

Edited:

@MarkJ: I should have given my cite for this: 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.

这篇关于什么是实现集合在VB6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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