红黑树
This commit is contained in:
25
main.cpp
Normal file
25
main.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user