红黑树

This commit is contained in:
2024-06-30 14:50:16 +08:00
commit 20ecee3980
6 changed files with 592 additions and 0 deletions

25
main.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include <iostream>
#include <RedBlackTree.h>
class RedBlackTree : public ling::RedBlackTree<int> {
protected:
[[nodiscard]] ling::Relation equal(const int &val1, const int &val2) const override {
if (val1 == val2)
return ling::Relation::EQUAL;
if (val1 < val2)
return ling::Relation::SMALL;
return ling::Relation::BIG;
}
};
int main() {
RedBlackTree tree;
for (int i = 0; i < 400000; i++)
tree.insert(i);
std::cout << "Max : " << tree.maximum()->value << std::endl;
return 0;
}