microsoft-visualbasic-runtime/ComponentModel/Algorithm/BinaryTree/TreeBase.vb

38 lines
1.2 KiB
VB.net
Raw Normal View History

2018-10-31 20:48:01 +08:00
Imports System.Runtime.CompilerServices
Namespace ComponentModel.Algorithm.BinaryTree
Public MustInherit Class TreeBase(Of K, V)
''' <summary>
''' The root node of this binary tree
''' </summary>
''' <returns></returns>
Public ReadOnly Property root As BinaryTree(Of K, V)
<MethodImpl(MethodImplOptions.AggressiveInlining)>
Get
Return _root
End Get
End Property
Protected _root As BinaryTree(Of K, V)
Protected ReadOnly compares As Comparison(Of K)
Protected ReadOnly views As Func(Of K, String)
Protected ReadOnly stack As New List(Of BinaryTree(Of K, V))
''' <summary>
''' Create an instance of the AVL binary tree.
''' </summary>
''' <param name="compares">Compare between two keys.</param>
''' <param name="views">Display the key as string</param>
Sub New(compares As Comparison(Of K), Optional views As Func(Of K, String) = Nothing)
Me.compares = compares
Me.views = views
End Sub
2018-10-31 21:10:03 +08:00
Public Function GetAllNodes() As BinaryTree(Of K, V)()
2018-10-31 20:48:01 +08:00
Return stack.ToArray
End Function
End Class
End Namespace