Collection Object

G

Guest

I am using Listdictionary to store key value pair as this doen't sort the key
on it's own. i want the Key value to appear in same sequence as i entered
while retreiving. i can't use the listdictionary as the items i am storing
goes above 10 and which is not recommended for the large collection. i can't
use Hashtable as it sort the collection on the hash code of the key.

i there any collection object which i can use that will give result back the
way i entered in it?
 
H

Helge Jensen

Swap said:
I am using Listdictionary to store key value pair as this doen't sort the key
on it's own. i want the Key value to appear in same sequence as i entered
while retreiving. i can't use the listdictionary as the items i am storing
goes above 10 and which is not recommended for the large collection. i can't
use Hashtable as it sort the collection on the hash code of the key.

Such a collection is called a linked hashtable. JAVA have such a
data-tructure called java.util.LinkedHashMap.
i there any collection object which i can use that will give result back the
way i entered in it?

Not in System.Collections. You can easily implement one though. If you
never remove items from you dictionary, you can simply maitain a
separate IList of keys which you add to when items are added to your
dictionary.

If you also need to remove items, you can map keys, not into the
user-passed value, but to a double-linked data-structure, like:

class Value {
public Value Next;
public Value Previous;
public Object UserValue;
}

and maintain the links when inserting and removing items.
 
J

Jon Shemitz

Swap said:
I am using Listdictionary to store key value pair as this doen't sort the key
on it's own. i want the Key value to appear in same sequence as i entered
while retreiving. i can't use the listdictionary as the items i am storing
goes above 10 and which is not recommended for the large collection. i can't
use Hashtable as it sort the collection on the hash code of the key.

i there any collection object which i can use that will give result back the
way i entered in it?

Sure. An ArrayList. Or a List<T>.
 

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