自己用模板实现的红黑树,算是对红黑树有了一个深入的了解.
测试代码如下:
#include <iostream>
#include "rb_tree.h"
void test()
{
rb_tree<int, int> ltree;
std::cout << "the tree is empty: " << (ltree.empty() ? "true" : "false") << std::endl;
for(int i = 0; i < 15; i++) {
ltree.insert(i, i);
}
ltree.show_tree();
}
int main(int argc, char* argv[])
{
test();
return 0;
}
红黑树的代码位置:
http://www.cppblog.com/Files/hdqqq/rb_tree.zip