This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/DataStructure/Code/ex10/binnode.hpp

53 lines
874 B
C++
Raw Permalink Normal View History

2021-12-03 07:26:29 +00:00
#ifndef _binnode_hpp_
#define _binnode_hpp_
#include <iostream>
#include <string>
#define binNodeArray(T) binNode<T> *
template <class T>
class binNode
{
public:
T data;
std::string pos;
binNode *parent;
binNode *lc;
binNode *rc;
~binNode()
{
2021-12-03 09:46:47 +00:00
if(isLC(this))
parent->lc = NULL;
else
parent->rc = NULL;
2021-12-03 07:26:29 +00:00
delete lc;
delete rc;
}
binNode()
{
parent = NULL;
lc = NULL;
rc = NULL;
}
binNode(binNode *p, binNode *l, binNode *r)
{
parent = p;
lc = l;
rc = r;
}
bool operator>(binNode const &bn)
{
return data > bn.data;
}
bool operator<(binNode const &bn)
{
return data < bn.data;
}
bool operator==(binNode const &bn)
{
return data == bn.data;
}
};
#endif