-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryNode.h
More file actions
54 lines (38 loc) · 1.59 KB
/
BinaryNode.h
File metadata and controls
54 lines (38 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Created by Frank M. Carrano and Tim Henry.
// Copyright (c) 2013 __Pearson Education__. All rights reserved.
// Modified by Ioannis Stamos and Yosef Yudborovsky
#ifndef TEACH_CSCI235_BST_BINARY_NODE_H_
#define TEACH_CSCI235_BST_BINARY_NODE_H_
#include <iostream>
using namespace std;
template<class ItemType, class OtherType>
class BinaryNode
{
public:
BinaryNode();
BinaryNode(const ItemType& an_item);
/* BinaryNode(const ItemType& anItem, */
/* BinaryNode<ItemType>* leftPtr, */
/* BinaryNode<ItemType>* rightPtr); */
void SetItem(const ItemType& an_item);
void SetOther(const OtherType& other); // (const OtherType& other)
ItemType GetItem() const;
OtherType GetOther() const;
OtherType &GetOtherReference();
bool IsLeaf() const;
BinaryNode<ItemType, OtherType>* GetLeftPtr() const;
BinaryNode<ItemType, OtherType>* GetRightPtr() const;
void SetLeftPtr(BinaryNode<ItemType, OtherType>* leftPtr);
void SetRightPtr(BinaryNode<ItemType, OtherType>* rightPtr);
void addLine(int lineNum); // Adds line number to other
void displayLines(); // Display line numbers from the list
void displayWordCount(); // Displays count of words
private:
ItemType item_; // Data portion (key)
OtherType other_; // Data portion (value)
// int lineNum;
BinaryNode<ItemType, OtherType>* left_ptr_; // Pointer to left child
BinaryNode<ItemType, OtherType>* right_ptr_; // Pointer to right child
}; // end BinaryNode
#include "BinaryNode.cpp"
#endif // TEACH_CSCI235_BST_BINARY_NODE_H_