本文整理汇总了C++中TreeNode::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::clear方法的具体用法?C++ TreeNode::clear怎么用?C++ TreeNode::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: randomForestClassifyThread
void* randomForestClassifyThread(void* index) {
int number = *(int*)index;
vector<int> result;
set<int> attributes = getRandomAttributes();
vector<int> samples = getRandomSampleIndexs();
TreeNode* tree = buildDecisionTree(samples, attributes, samples);
for (int j = 0; j < allTests.size(); j++) {
result.push_back(findPath(tree, allTests[j]));
}
cout << number << endl;
results[number] = result;
tree->clear();
delete tree;
}
示例2: randomForestClassify
void randomForestClassify() {
for (int i = 0; i < TREE_NUM; i++) {
vector<int> result;
set<int> attributes = getRandomAttributes();
vector<int> samples = getRandomSampleIndexs();
TreeNode* tree = buildDecisionTree(samples, attributes, samples);
for (int j = 0; j < allTests.size(); j++) {
result.push_back(findPath(tree, allTests[j]));
}
cout << "Run tree " << i << " finish" << endl;
results[i] = result;
tree->clear();
delete tree;
}
}
示例3: insert
iterator insert(StoredObject&& toStore)
{
TreeNode* node = getNode(toStore.location);
if (node->level() > 0)
{
// We store one element at time so there will be a moment before node overflow when its
// count will be equal capacity. Then we'll relocate all its elements to the new child
// nodes. At worst scenario, all elements will be relocated to the same node, so its
// count() will be again equal to capacity. The loop ends when at least one element is
// relocated to the another child node.
while (node->count() == nodeCapacity && node->level() > 0)
{
typename TreeNode::iterator it;
typename TreeNode::iterator itEnd = node->end();
for (it = node->begin(); it != itEnd; ++it)
{
node->child(it->location).insert(std::move(*it));
}
node->clear();
node = &(node->child(toStore.location));
}
}
return iterator(node, node->insert(std::move(toStore)));
}
示例4: zigzagLevelOrder
vector<vector<int> > zigzagLevelOrder(TreeNode *root) {
vector<vector<int>> answer;
vector<int> level;
if(root==NULL) {
return answer;
}
queue<TreeNode *> q;
q.push(root);
int num = 1;
int row = 0;
TreeNode *temp;
while(!q.empty()){
temp = q.front();
q.pop();
level.push_back(temp->val);
num--;
if(temp->left!=NULL){
q.push(temp->left);
}
if(temp->right!=NULL){
q.push(temp->right);
}
if(num==0){
num = q.size();
if(row%2==0){
answer.push_back(level);
}else{
vector<int> temp;
for(int i = level.size() - 1 ; i >= 0; --i) {
temp.push_back(level[i]);
}
answer.push_back(temp);
temp.clear();
}
level.clear();
row++;
}
}
return answer;
}