Want a key value collection that maintains ordering

B

Bruce Wood

Going back to your original post...
is there a key value collection in .Net that maintains the
ordering in which I add items.
I would prefer just to use some collection that
maintains the ordering in which I add things (like ArrayList), but that
maps a key to a value.

So... this isn't exactly what you want after all. What you want is
something that maps a _multi-part_ key onto a value, or perhaps stores
values in a hierarchical structure but also in insertion order? Your
solution isn't "simpler" than mine... rather, it solves a different
problem.

Since your original post doesn't completely state your problem, could
you restate the problem so that we understand, completely, what it is
that you need to do?
 
I

illegal.prime

I seem to have offended you - sorry for that.

I have always wanted the same thing, but you're right I could have
provided more details on what I want.

I still want a "key value collection in .Net that maintains the
ordering in which I add items. I would prefer just to use some
collection that maintains the ordering in which I add things (like
ArrayList), but that maps a key to a value."

However, this key value collection also needs to be able to hold a
hierarchy of collections. Therefore, the values need to be able to be
traversed - since they values could themselves be key value
collections.

I have a working solution, if not an efficient one. I'm just surprised
that short of getting .Net 2 there is no generic solution.

Thanks,
Novice
 
B

Bruce Wood

Don't worry. You didn't offend me. I was just pointing out that your
requirements seemed to have changed, in hopes of getting more details.

Your solution may be efficient enough if there are few elements in your
collection. If there are very many, though, you may want to implement
Brian Gideon's class and then just use a hierarchy of them.

I don't believe that there's a generic solution even in .NET 2.0
(unless I missed something in the conversation). Yours isn't a very
common requirement: most people want either a straight hash or a
_sorted_ list of items with quick access by key.
 
B

Brian Gideon

Bruce said:
Your solution may be efficient enough if there are few elements in your
collection. If there are very many, though, you may want to implement
Brian Gideon's class and then just use a hierarchy of them.

I should give credit where credit is due. It isn't actually my class.
Someone else wrote that article :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top