Re: Efficient Data Structures
- From: Gabe Moothart <gabe@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 13 Dec 2005 09:53:01 -0800
Hi,
I agree with the others that the Red/Black tree should be easy to fix, and the SortedList will probably do what you want, too.
But you could also try my favorite data structure, the SkipList. There is a c# implementation on CodeProject here: http://www.codeproject.com/csharp/SkipList1.asp.
The article includes benchmarks against a SortedList, and SkipList beats it handily. SkipList is also much simpler than a Red/Black tree, and should give better average performance. You'll have to test this to be sure, though.
Gabe
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: Michael S
- Re: Efficient Data Structures
- References:
- Efficient Data Structures
- From: Curious
- Re: Efficient Data Structures
- From: Rick Lones
- Efficient Data Structures
- Prev by Date: Re: C# Open Source Projects
- Next by Date: Re: A simple employee class : OOP Study
- Previous by thread: Re: Efficient Data Structures
- Next by thread: Re: Efficient Data Structures
- Index(es):
Relevant Pages
|