CollectionBase

  • Thread starter Thread starter Johan Karlsson
  • Start date Start date
J

Johan Karlsson

Hi!

When using the Add method of a class inherited from collectionBase, you get
an indexnumber returned that represents the position of newly inserted
object into the collection. Is this number constant? Lets say if I remove an
item "lower" in the list does the index change for the items above?

Thanks
/Johan
 
Lets say if I remove an item "lower" in the list does the index change for the items above?

Yes.
 
The number is NOT constant. Changes to the collection below the index you
are interested in will change all the indexes above it.
 
That's what I though...

I used the index as a quicklookup of items in a collection, that will not
work in production then.

So if I need a collection that is "fast-searchable", I should create a class
that uses a hashTable instead to store the collection behind the scenes?

Thanks

Johan
 
Johan,
It sounds like you want to inherit from DictionaryBase instead of
CollectionBase.

CollectionBase uses an ArrayList as its underlying storage mechanism, while
DictionaryBase uses a HashTable as its underlying storage mechanism.

Hope this helps
Jay
 
Back
Top