-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBSTData.cpp
More file actions
112 lines (104 loc) · 3.1 KB
/
Copy pathBSTData.cpp
File metadata and controls
112 lines (104 loc) · 3.1 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* @file BSTData.h
* @author Alex Lambert
*
* Description:
* - Interface for objects that defines comparison operators to compare
* data within the Binary Search Trees
* - Includes comparison operators (<,<=,>,>=,==,!=)
* - Includes no data members
*
* Assumptions/Implementation:
* - Inheriting classes must implement display and getComp
* - Uses getComp to compare BSTDatas of the same derived type
*/
#include "BSTData.h"
//---------------------------------------------------------------------------
/** ~BSTData()
* Default Destructor
*
* Destroys the BSTData
* @pre None
* @post All memory used by the BSTData is deallocated
*/
BSTData::~BSTData() { }
//---------------------------------------------------------------------------
/** operator<()
* Less Than Operator
*
* Determines if the left side item is less than the right
* @pre Both items are of the same type
* @post None.
* @return true returned when left is less than right, false otherwise
*/
bool BSTData::operator<(const BSTData& rhs) const
{
return getComp(rhs) < 0;
}
//---------------------------------------------------------------------------
/** operator<=()
* Less Than or Equal Operator
*
* Determines if the left side item is less than or equal to the right
* @pre Both items are of the same type
* @post None.
* @return true returned when left is less than or equal to the right,
* false otherwise
*/
bool BSTData::operator<=(const BSTData& rhs) const
{
return getComp(rhs) <= 0;
}
//---------------------------------------------------------------------------
/** operator>()
* Greater Than Operator
*
* Determines of the left side item is greater than the right
* @pre Both items are of the same type
* @post None.
* @return true returned when left is greater than right, false otherwise
*/
bool BSTData::operator>(const BSTData& rhs) const
{
return getComp(rhs) > 0;
}
//---------------------------------------------------------------------------
/** operator>=()
* Greater Than or Equal Operator
*
* Determines of the left side item is greater than or equal to the right
* @pre Both items are of the same type
* @post None.
* @return true returned when left is greater than or equal to right,
* false otherwise
*/
bool BSTData::operator>=(const BSTData& rhs) const
{
return getComp(rhs) >= 0;
}
//---------------------------------------------------------------------------
/** operator==()
* Equivalence Operator
*
* Determines if the right and left items are equivalent
* @pre Both items are of the same type
* @post None.
* @return true returned when left is equal to right, false otherwise
*/
bool BSTData::operator==(const BSTData& rhs) const
{
return getComp(rhs) == 0;
}
//---------------------------------------------------------------------------
/** operator==()
* Non-Equivelence Operator
*
* Determines if the right and left items are not equivalent
* @pre Both items are of the same type
* @post None.
* @return true returned when left is not equal to right, false otherwise
*/
bool BSTData::operator!=(const BSTData& rhs) const
{
return getComp(rhs) != 0;
}