collections?

Are Collections deprecated or to be deprecated?

Collection was the forefather of Dictionary and Dictionary was introduced because it was significantly faster.

If memory serves, Collection has some features that the Dictionary lacks, but you should probably use Dictionary whether Collection is officially deprecated or not.

From the docs

I do hope that collections don’t go away, I’ve started using them to help with an issue I have.

I stopped using collections and started using arrays and dictionaries, but there is something I miss about collections and that is being able to remove and object by specifying the object.

dim x as new object dim c as new collection c.add(x) .... c.remove(x)

vs having to find the index of x in the array and remove(index), also to remove a bunch of objects from an array you have to start at the last and move towards the first.

Dictionaries bother because I think that when you iterate through them, the order is not necessarily the order in which things were added.

You can use the array.indexof method to find the index of an object in an array.

Dim x as new MyObject dim arMyArray() as MyObject arMyArray.append x . . . . dim iIndex as integer iIndex = arMyArray.IndexOf(x) arMyArray.remove(iIndex)

[quote=62571:@Bob Keeney]You can use the array.indexof method to find the index of an object in an array.

Dim x as new MyObject dim arMyArray() as MyObject arMyArray.append x . . . . dim iIndex as integer iIndex = arMyArray.IndexOf(x) arMyArray.remove(iIndex)[/quote]

Note that IndexOf has O(n) complexity as does Collection.Item(string). Dictionary.Value, on the other hand, has an average O(1) complexity and a worst case of O(n). If your data set is small, it’s not much of a concern but if it gets quite large it starts to matter.

Now you have me curios what you are able do with a collection that you would use that instead of a dictionary.

You remember my array in dictionary issue? Using a collection solved the situation for me.