21 lines
302 B
C++
21 lines
302 B
C++
#include "RBTree.h"
|
||
using namespace std;
|
||
int main() {
|
||
RBTree<int> t;
|
||
//一定关注NIL指针的使用,所有悬挂出的节点都要用NIL
|
||
t.insert(8);
|
||
t.insert(5);
|
||
t.insert(3);
|
||
t.insert(2);
|
||
t.insert(7);
|
||
t.insert(1);
|
||
t.inorder();
|
||
cout << endl;
|
||
t.erase(7);
|
||
t.inorder();
|
||
return 0;
|
||
}
|
||
/*
|
||
1 2 3 5 7 8
|
||
1 2 3 5 8
|
||
*/ |