Click here to Skip to main content
12,625,694 members (36,537 online)
Click here to Skip to main content

Stats

67.1K views
1K downloads
40 bookmarked
Posted

Treaps in C#

, 15 Sep 2004 CPOL
A Treap implementation in C#.
TreapCS
bin
release
TreapCS.dll
obj
Release
temp
TempPE
Test
bin
release
Test.exe
TreapCS.dll
obj
Debug
temp
TempPE
Release
temp
TempPE
Test.csproj.user
TreapCS.csproj.user
using System;

namespace Test
{
	//
	// demonstrates using a key embedded with an object
	//
	public class MyKeyObj : IComparable
	{
		private int     intKey;
		private string  strData;
		
		public int Key
		{
			get
            {
				return intKey;
			}
			
			set
			{
				intKey = value;
			}
		}
		public string Data
		{
			get
            {
				return strData;
			}
			
			set
			{
				strData = value;
			}
		}
		public MyKeyObj(int key, string data) 
        {
			this.Key    = key;
			this.Data   = data;
		}

		public int CompareTo(object key)
		{
			if(Key > ((MyKeyObj)(key)).Key)
				return 1;
			else
			if(Key < ((MyKeyObj)(key)).Key)
				return -1;
			else
			{
				return 0;
            }
		}
		public override string ToString()
		{
			return Key.ToString();
		}
	}
}

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 Code Project Open License (CPOL)

Share

About the Author

RoyClem
Architect
United States United States
Roy is a software developer who digs all aspects of software development, from design and architecture to implementation.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161205.3 | Last Updated 15 Sep 2004
Article Copyright 2004 by RoyClem
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid