This is a simple binary tree class that I wrote while writing a PDA program. It should work on any platform supporting the .NET Framework, and should be simple to port to any other .NET language. To use it, simply have your classes inherit from
BinaryBase and then you can add your class to the tree. Be sure to only use one type of object per tree, or it will throw an exception.
Public Class MyClass Inherits BinaryBase
Private m_ID as integer
Public Overrides ReadOnly Property ID() As Integer
dim theObject as New MyClass
dim theTree as New BinaryTree(theObject)
Now you can add as many new
MyClass objects as you want to the tree by calling
dim theOtherObject as New MyClass
The tree uses the inherited
ID property to put the objects into the proper order and to find items, so be sure that
ID is always unique; for example, the primary key in a SQL table. Also, the tree does type checking to be sure you don't mismatch items since that would mean the possibility of two different IDs which could mess things up, so be sure to use different trees for different types.
If you have any questions or comments, please feel free to contact me. I am busy a lot of the time, but I will try to get back to you as soon as possible ;)