Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
6
Добавлен:
26.03.2015
Размер:
2.7 Кб
Скачать
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "BinaryNode"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
' ************************************************
' BinNode.CLS
'
' Node class for binary tree example program.
' ************************************************
' Copyright (C) 1997 John Wiley & Sons, Inc.
' All rights reserved. See additional copyright
' information in RIGHTS.TXT.
' ************************************************
Option Explicit

Public LeftChild As BinaryNode
Public RightChild As BinaryNode

Public Box As Label
' ************************************************
' Delete the descendant node. Return True if the
' node is deleted.
' ************************************************
Public Function DeleteDescendant(target As BinaryNode) As Boolean
If LeftChild Is target Then
Set LeftChild = Nothing
DeleteDescendant = True
Exit Function
End If
If RightChild Is target Then
Set RightChild = Nothing
DeleteDescendant = True
Exit Function
End If

' It's not one of our children. Recursively
' check the descendants.
If Not (LeftChild Is Nothing) Then
If LeftChild.DeleteDescendant(target) Then
DeleteDescendant = True
Exit Function
End If
End If
If Not (RightChild Is Nothing) Then
If RightChild.DeleteDescendant(target) Then
DeleteDescendant = True
Exit Function
End If
End If
End Function
' ************************************************
' Find the node that corresponds to the Label.
' ************************************************
Public Function FindNode(ctl As Label) As BinaryNode
Dim node As BinaryNode

' See if we are the one.
If ctl = Box Then
Set FindNode = Me
Exit Function
End If

' See if the left child is the one.
If Not LeftChild Is Nothing Then
Set node = LeftChild.FindNode(ctl)
If Not (node Is Nothing) Then
Set FindNode = node
Exit Function
End If
End If

' See if the right child is the one.
If Not (RightChild Is Nothing) Then
Set node = RightChild.FindNode(ctl)
If Not (node Is Nothing) Then
Set FindNode = node
Exit Function
End If
End If

Set FindNode = Nothing
End Function

' ************************************************
' Unload the node's label control.
' ************************************************
Private Sub Class_Terminate()
Unload Box
End Sub


Соседние файлы в папке CH6
  • #
    26.03.20159.7 Кб5BINARY.FRM
  • #
    26.03.201512 б6BINARY.FRX
  • #
    26.03.2015391 б5BINARY.VBP
  • #
    26.03.20152.7 Кб6BINNODE.CLS
  • #
    26.03.20155.88 Кб6FSTAR.BAS
  • #
    26.03.20157.86 Кб5FSTAR.FRM
  • #
    26.03.201512 б5FSTAR.FRX
  • #
    26.03.2015376 б5FSTAR.VBP
  • #
    26.03.20157.96 Кб5NAry.frm