-
Notifications
You must be signed in to change notification settings - Fork 0
/
BinNode.h
36 lines (25 loc) · 916 Bytes
/
BinNode.h
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
// From the software distribution accompanying the textbook
// "A Practical Introduction to Data Structures and Algorithm Analysis,
// Third Edition (C++)" by Clifford A. Shaffer.
// Source code Copyright (C) 2007-2011 by Clifford A. Shaffer.
// 05/15/2023 by Prof Sipantzi
#pragma once
// Binary tree node abstract class
template <class E> class BinNode {
public:
virtual ~BinNode() {} // Base destructor
// Return the node's value
virtual E& element() = 0;
// Set the node's value
virtual void setElement(const E&) = 0;
// Return the node's left child
virtual BinNode* left() const = 0;
// Set the node's left child
virtual void setLeft(BinNode*) = 0;
// Return the node's right child
virtual BinNode* right() const = 0;
// Set the node's right child
virtual void setRight(BinNode*) = 0;
// Return true if the node is a leaf, false otherwise
virtual bool isLeaf() = 0;
};