Old style Collections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I find the Generic collection classes really usefull, so usefull in fact that
I do not usually use the old style collections like ArrayList and Hashtable.

In fact if I did need a collection of potentially anything I would use a
List(of object) rather than an ArrayList.

Are there any occaisions where the old collections are preferable?

Guy
 
I find the Generic collection classes really usefull, so usefull in fact that
I do not usually use the old style collections like ArrayList and Hashtable.

In fact if I did need a collection of potentially anything I would use a
List(of object) rather than an ArrayList.

Are there any occaisions where the old collections are preferable?

Guy

None come to mind.
 
I find the Generic collection classes really usefull, so usefull in fact
that
I do not usually use the old style collections like ArrayList and Hashtable.

In fact if I did need a collection of potentially anything I would use a
List(of object) rather than an ArrayList.

Are there any occaisions where the old collections are preferable?

I still have one such case remaining (all others converted to generics). It
is a queue where each queue entry is an array of objects. By convention, the
zero'th array element is a string whose value tells you how to interpret the
remaining array elements. The dequeueing thread needs to operate
sequentially on the queue (that's why a queue in the first place), and I
can't see a good way to convert to generics.
 
I still have one such case remaining (all others converted to generics). It
is a queue where each queue entry is an array of objects. By convention, the
zero'th array element is a string whose value tells you how to interpret the
remaining array elements. The dequeueing thread needs to operate
sequentially on the queue (that's why a queue in the first place), and I
can't see a good way to convert to generics.

dim q as new queue(of object())()

:)
 
dim q as new queue(of object())()

Well, sure, but I'd still have 'object' rather than something more specific,
and I'd still be Ctype'ing. If my solution were just an Object rather than
an Array of Objects, then
dim q as new queue(of object)
would be using a generic without purpose.

I guess the more direct answer to guy's original question is this: a queue
of diverse objects that do not have any common inheritence other than
'object' and where their sequencing is all important.
 
Well, sure, but I'd still have 'object' rather than something more specific,
and I'd still be Ctype'ing. If my solution were just an Object rather than
an Array of Objects, then
dim q as new queue(of object)
would be using a generic without purpose.

I guess the more direct answer to guy's original question is this: a queue
of diverse objects that do not have any common inheritence other than
'object' and where their sequencing is all important.

I was only funning you. That's why I had the :) in my message....
Really with queue, you are probably not gaining anything - there isn't
even the extra convienience of the new findx methods (it's queue,
duh!). I might be tempted to do a performance comparison, just to see
if there were any new optimizations in the new generic queue, but
somehow, I doubt it.
 
guy said:
Are there any occaisions where the old collections are preferable?

I frequently create my own strongly-typed collection classes by deriving
from CollectionBase and adding my own Add, Remove and Item properties. I'd
love to switch these over to use Generics because the collection classes are
very dull and all virtually identical.

However, is there a generic collection class which allows me to add items
with a key, request the item by key, but also request the item by index? The
items when queried by index will need to be returned in the order in which
they were added.

I can see generic collections which allow me to retrieve objects by key OR
by index, but I've not spotted one that lets me use both at the same time.
Am I missing one?
 
guy said:
I find the Generic collection classes really usefull, so usefull in fact
that
I do not usually use the old style collections like ArrayList and
Hashtable.

In fact if I did need a collection of potentially anything I would use a
List(of object) rather than an ArrayList.

Are there any occaisions where the old collections are preferable?

Existing and well-tested code. A rewrite for the sake of a rewrite always
bears the potential of introducing new bugs.
 
Back
Top