Click here to Skip to main content
15,886,519 members
Articles / General Programming / Performance

B-Tree Sorted Dictionary

Rate me:
Please Sign up or sign in to vote.
4.96/5 (48 votes)
26 Jan 2024MIT8 min read 180.7K   4.8K   140  
In-memory B-Tree sorted dictionary
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Sop.Collections.Generic.BTree;

namespace BTreeSample
{
    class Program
    {
        static void Main(string[] args)
        {
            BTreeDictionary<string, string> WordLookup = new BTreeDictionary<string, string>();
            WordLookup.Add("Hello", "Cool World!");
            WordLookup.Add("Hello", "Cooler World!");
            WordLookup.Add("Brown", "Fox!");
            WordLookup.Add("Foo", "Bar");
            string v;
            if (WordLookup.TryGetValue("Foo", out v))
                Console.WriteLine("Foo was found! Value = {0}", v);

            if (WordLookup.MoveFirst())
            {
                Console.WriteLine();
                Console.WriteLine("Words in Lookup:");
                do
                {
                    Console.WriteLine("Key:{0}, Value={1} ", WordLookup.CurrentKey, WordLookup.CurrentValue);
                } while (WordLookup.MoveNext());
            }

            Console.ReadLine();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
United States United States
Ex Google, ex Microsoft
I'm just fresh off from a software eng'g gig & is looking forward to my next.
Pls. do drop me a line @gerardorecinto@yahoo.com if interested or having any question/feedback on these Open Source projects.

I'm excited to help/volunteer my services.
Have a great day!

Comments and Discussions