代码拉取完成,页面将自动刷新
#pragma once
#ifndef O3D_BS_TREE_H
#define O3D_BS_TREE_H
template<typename T>
class BSTree {
public:
T val_;
BSTree* leftNode_ = nullptr;
BSTree* rithrNode_ = nullptr;
void add(BSTree& it) {
this->add(&it);
}
void add(BSTree* it) {
if (!leftNode_ && it->val_ <= this->val_) {
leftNode_ = it;
return;
}
if (!rithrNode_ && it->val_ > this->val_) {
rithrNode_ = it;
return;
}
if (it->val_ <= this->val_) {
this->leftNode_->add(it);
} else {
this->rithrNode_->add(it);
}
}
};
template<>
class BSTree<unsigned char> {
public:
BSTree<unsigned char>(const uint8_t& ival) :val_(ival) {
}
BSTree<unsigned char>() : val_(0) {
}
unsigned char val_;
BSTree <unsigned char>* leftNode_ = nullptr;
BSTree <unsigned char>* rithrNode_ = nullptr;
void add(BSTree <unsigned char>& it) {
this->add(&it);
}
void add(BSTree <unsigned char>* it) {
if (!leftNode_ && it->val_ <= this->val_) {
leftNode_ = it;
return;
}
if (!rithrNode_ && it->val_ > this->val_) {
rithrNode_ = it;
return;
}
if (it->val_ <= this->val_) {
this->leftNode_->add(it);
} else {
this->rithrNode_->add(it);
}
}
};
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。