Click here to Skip to main content
15,892,072 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 181.8K   4.8K   140  
In-memory B-Tree sorted dictionary
/* 
 * Copyright(c) 2002 Gerardo Recinto/4A Technologies (http://www.4atech.net)
 */

#region History Log
//Log :
// 6/3/2001  .NET migration
// 6/18/1998 Initial version.
#endregion

namespace Sop.Collections.BTree
{
    using System.Threading;
    /// <summary>
    ///    SingleThreadAccess contains api for single thread access to a resource.
    /// </summary>
    internal class SingleThreadAccess	// : ISingleThreadAccess
    {
		/// <summary>
		/// Default constructor
		/// </summary>
		public SingleThreadAccess() {}

		/// <summary>
		/// Lock this resource for update. This allows only a single thread to get
		/// access to the resource.
		/// </summary>
		public void Lock()
		{
			Monitor.Enter(this);
		}
		/// <summary>
		/// Lock this resource for update. This allows only a single thread to get
		/// access to the resource.
		/// </summary>
		/// <param name="Value">object resource to synchronize access with</param>
		static public void Lock(object Value)
		{
			Monitor.Enter(Value);
		}

		/// <summary>
		/// Unlock this resource so other thread(s) may acquire a Lock on it.
		/// </summary>
		public void Unlock()
		{
			Monitor.Exit(this);
		}
		/// <summary>
		/// Unlock this resource so other thread(s) may acquire a Lock on it.
		/// </summary>
		/// <param name="Value">object resource to synchronize access with</param>
		static public void Unlock(object Value)
		{
			Monitor.Exit(Value);
		}
	}
}

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