Re: Efficient Data Structures
- From: Rick Lones <WrlonesX@xxxxxxxxxxxxx>
- Date: Tue, 13 Dec 2005 06:29:35 -0500
Curious wrote:
I am searching for a data structure that stores key-value pairs in it. This data structure is to hold large amounts of key-value pairs, and so needs to be efficient both in insertion and deletion.
Does anybody know of ready data structures that can be freely used under the .Net framwork.
Also:
I forgot to mention, that the data needs to be maintained sorted. When removing the data, the minimum key with its data is to be removed.
You won't *necessarily* get great efficiency on both insertion and removal. But given your description so far it sounds as if you can - I would try a SortedList. The insertion uses .Add(object key, object value) - which *should* be efficient, at least if the key elements arrive in anything like random order. (Test it!) You can remove elements either with .Remove(object key) or ..RemoveAt(int index) - index being 0 in your case of removing the element with least key. Either of these *should* be quite efficient (O(log n) at worst) *if* the list is internally maintained sorted as per the documentation. (Again, test it!)
HTH, -rick- .
- Follow-Ups:
- Re: Efficient Data Structures
- From: Brian Gideon
- Re: Efficient Data Structures
- From: Bruce Wood
- Re: Efficient Data Structures
- From: Gabe Moothart
- Re: Efficient Data Structures
- References:
- Efficient Data Structures
- From: Curious
- Efficient Data Structures
- Prev by Date: Re: Storing information in an image
- Next by Date: Re: Issue while closing a StreamWriter
- Previous by thread: Re: Efficient Data Structures
- Next by thread: Re: Efficient Data Structures
- Index(es):
Relevant Pages
|