1 Attachment(s)
Replacing the vb collection object (Warning - this is a lot to read)
Like everyone else I think the VB Collection object is missing some features. I thought about using a Dictionary but I have read that deploying scrunn.dll can be problamatic. So, I set out on a quest to replace it with something else.
First I used an object called Hive (freevbcode.com):
Hive is a drop in replacement for the collection object. The source is in vb and is freelly available, but it wasn't very fast at all.
Next I found flexbag (http://www.spidereye.com/software/flexbag/) . The Flexbag object is pretty fast, and is a drop in replacement for the vb collection. It offers some nice extra feature, and is free to use. But inserting at the first item is incredibly slow and the source is not available because it's a compiled dll programmed in ATL and C++.
Then I found the HashTable and LinkedList classes(vb2themax.com):
There both pretty fast, free to use, the source is in VB6 and available. The linkedlist object is very fast but doen't use keys. The HashTable is fast but only allows inserting past the last item. There is another big problem with both of these classes, the Remove methods do not work correctlly at all. Fortunatley these things can be fixed.
Lastly I found the Indexed Object Collections (vbaccelerator.com):
Very fast but they use indexe number only, instead of keys. The code for this is in vb6, freelly available, and very advanced (it uses a typelib). Editing the source would not easy for noobie at all.
So, with these finding in hand I decided to make my own collection object that could replace the standard collection with as little fuss as possible and with as many features as possible. I took the linkedlist and hashtable concept and merged them. Now I have a double linked list with a hashtable of keys. I'm calling this object either KeyedLinkedList or HashList.
The HashList/KeyedLinkedList is:
Openly available with vb6 source and feature rich.
can handle DuplicateKeys
return a array of the keys in use
return an array of the values/objects stored in the list
can move to the first item, last item, next item, previous item, or foward/back by a given number.
Ignore case sensitive keys macthing.
determine wether or not it's at the BOL or EOL.
determine whether or not a key exists.
Allow you to set the size of the list. This speeds up the appending and insertion process.
Allow you to set the chunksize of the list. this determines how much the list grows by when it runs out of empty slot for appending/inserting.
automatically create 8, 10, 12, 32 character keys if none is supplied.
allows empty keys.
return an item by key or index.
return the next item to use the same key.
remove an item by key or index.
remove all items.
clear all items and set the list back to its default size. this helps reclaim memory... I think.
return a key by index number.
return a index number by key.
return its current position in the list.
insert items to the end of the list.
insert items before or after others item in the list
And my initial testing shows it to be faster than most of the collection objects mentioned above.
With all that said let me also state that it does not provide support for enumerating throught the list with the IUknown interface, beside that it's a drop in replacement for the vb collection object. It also has one dependency class called StringAppendar which is a very fast vb6 class object for concantanating strings. StringAppendar is only used to automatically create keys and can be replaced with a string varaible. I found string appendar on the web but can't remember where.
so try it out and tell me what you think. If there are no bugs in it than I'll post it in the codebank in a few days.
Re: Replacing the vb collection object (Warning - this is a lot to read)
Quote:
Originally posted by frigginjerk
I thought about using a Dictionary but I have read that deploying scrunn.dll can be problamatic.
In all the years I've been using the Dictionary object, I've never once deployed it - and I've written a lot of applications for download from websites like download.com
Just thought I'd mention that :)
Re: Replacing the vb collection object (Warning - this is a lot to read)
I know this is a really old thread, but I just wanted anyone interested to know that I posted a final version of clsLinkedListAdvanced in the codebank. I fixed some bugs and made it faster.
Hope, I dont offend anybody by bringing this up so long after the thread started.
Re: Replacing the vb collection object (Warning - this is a lot to read)
Re: Replacing the vb collection object (Warning - this is a lot to read)
If anyone else comes across this thread in a search, the Codebank article is:
http://www.vbforums.com/showthread.php?t=387848