30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1162 Data Structures and Collections Chapter 23<br />

1 ' Fig. 23.19: TreeNode.vb<br />

2 ' Class CTreeNode represents a node in a CTree.<br />

3<br />

4 Public Class CTreeNode<br />

5 Private mLeftNode As CTreeNode<br />

6 Private mData As Integer<br />

7 Private mRightNode As CTreeNode<br />

8<br />

9 ' initialize data and make that a leaf node<br />

10 Public Sub New(ByVal nodeData As Integer)<br />

11 mData = nodeData<br />

12 mRightNode = Nothing ' node has no children<br />

13 LeftNode = Nothing ' node has no children<br />

14 End Sub ' New<br />

15<br />

16 ' property LeftNode<br />

17 Public Property LeftNode() As CTreeNode<br />

18<br />

19 Get<br />

20 Return mLeftNode<br />

21 End Get<br />

22<br />

23 Set(ByVal value As CTreeNode)<br />

24 mLeftNode = value<br />

25 End Set<br />

26<br />

27 End Property ' LeftNode<br />

28<br />

29 ' property Data<br />

30 Public Property Data() As Integer<br />

31<br />

32 Get<br />

33 Return mData<br />

34 End Get<br />

35<br />

36 Set(ByVal value As Integer)<br />

37 mData = value<br />

38 End Set<br />

39<br />

40 End Property ' Data<br />

41<br />

42 ' property RightNode<br />

43 Public Property RightNode() As CTreeNode<br />

44<br />

45 Get<br />

46 Return mRightNode<br />

47 End Get<br />

48<br />

49 Set(ByVal value As CTreeNode)<br />

50 mRightNode = value<br />

51 End Set<br />

52<br />

53 End Property ' RightNode<br />

Fig. 23.19 Tree-node data structure (part 1 of 2).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!