这篇教程C++ IsLeaf函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中IsLeaf函数的典型用法代码示例。如果您正苦于以下问题:C++ IsLeaf函数的具体用法?C++ IsLeaf怎么用?C++ IsLeaf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了IsLeaf函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: assertvoid Tree::ToFileNodeRooted(TextFile &File, unsigned uNodeIndex) const { assert(IsRooted()); bool bGroup = !IsLeaf(uNodeIndex) || IsRoot(uNodeIndex); if (bGroup) File.PutString("(/n"); if (IsLeaf(uNodeIndex)) File.PutString(GetName(uNodeIndex)); else { ToFileNodeRooted(File, GetLeft(uNodeIndex)); File.PutString(",/n"); ToFileNodeRooted(File, GetRight(uNodeIndex)); } if (bGroup) File.PutString(")"); if (!IsRoot(uNodeIndex)) { unsigned uParent = GetParent(uNodeIndex); if (HasEdgeLength(uNodeIndex, uParent)) File.PutFormat(":%g", GetEdgeLength(uNodeIndex, uParent)); } File.PutString("/n"); }
开发者ID:Unode,项目名称:ext_apps,代码行数:28,
示例2: NodeName/*virtual*/ string ComputationNodeBase::FormatOperationPrototype(const string& extraArgs) const{ string prototype; prototype += msra::strfun::strprintf("%ls = %ls", NodeName().c_str(), OperationName().c_str()); // arguments of operation if (IsLeaf()) prototype += "()"; else { prototype += " ("; for (size_t i = 0; i < GetNumInputs(); i++) { const auto& child = m_inputs[i]; if (i > 0) prototype += ", "; if (child) prototype += msra::strfun::strprintf("%ls", child->NodeName().c_str()); else prototype += "NULL"; } prototype += extraArgs; prototype += ")"; } // type (tensor dimensions) of operation prototype += " : "; if (!IsLeaf()) { //prototype += "("; for (size_t i = 0; i < GetNumInputs(); i++) { const auto& child = m_inputs[i]; if (i > 0) prototype += ", "; if (child == nullptr) { prototype += "NULL"; continue; } prototype += child->ShapeDescription().c_str(); } prototype += extraArgs; //prototype += ")"; } prototype += msra::strfun::strprintf(" -> %s", ShapeDescription().c_str()); return prototype;}
开发者ID:Soukiy,项目名称:CNTK,代码行数:53,
示例3: unitTestvoid unitTest() { TreeType tree = InitTree(); printf("After initlizing tree:/n"); PrintTree(tree); PositionType question = 0; PositionType answer = 5; printf("IsLeaf test 1: %s/n", IsLeaf(tree, question) ? "error" : "pass"); printf("IsLeaf test 2: %s/n", IsLeaf(tree, answer) ? "pass" : "error"); printf("Top test: %s/n", Top(tree) == 0 ? "pass" : "error"); printf("Question test 1: %s/n", strcmp(Question(tree, question), "Is it furry?") == 0 ? "pass" : "error"); printf("Question test 2: %s/n", strcmp(Question(tree, answer), "Is it a lizard?") == 0 ? "pass" : "error"); printf("%s/n", Question(tree, answer)); ReplaceNode(tree, 7, "a kitten", "Is it an adult?"); PrintTree(tree);}
开发者ID:Garyguo2011,项目名称:cs9x,代码行数:15,
示例4: main/* * Play the "animal" game, in which the program attempts to guess an animal * that the user is thinking of by asking yes or no questions. Eventually, * the program either will guess the user's animal or run out of questions * to ask. In the latter case, the program will ask the user to provide a * yes-or-no question that would distinguish between the user's animal and * the program's best guess. * The data structure of questions and guesses is essentially a binary tree, * with each internal node having a "yes" branch and a "no" branch. Leaves * of the tree represent animals to be guessed by the program. If the program * fails to guess the user's animal, it replaces one of the leaves of the tree * by a node containing the new question, whose children are the program's * best guess and the animal provided by the user. * The structure of the program is simple. It initializes the question/guess * data structure, then plays games as long as the user is interested. In each * game, the program starts at the top of the tree (the root) and progresses * toward the bottom (the leaves) depending on the user's responses. Once it * reaches a leaf, it either has won or lost, and handles the situation as * described above. */int main () { TreeType tree; PositionType pos; char *newQuestion, *newAnswer; tree = InitTree (); // unitTest(); printf("%s", "Think of an animal. I will try to guess what it is./n" "Please answer my questions with yes or no./n"); while (TRUE) { pos = Top (tree); while (!IsLeaf (tree, pos)) { pos = Answer (Question (tree, pos))? YesNode (tree, pos): NoNode (tree, pos); } if (Answer (Guess (tree, pos))) { printf ("I got it right!/n"); } else { GetNewInfo (tree, pos, &newAnswer, &newQuestion); ReplaceNode (tree, pos, newAnswer, newQuestion); } if (!Answer ("Want to play again? ")) { exit (0); } } return 0;}
开发者ID:Garyguo2011,项目名称:cs9x,代码行数:48,
示例5: GetAnyNonLeafNodeunsigned Tree::GetAnyNonLeafNode() const { for (unsigned uNodeIndex = 0; uNodeIndex < m_uNodeCount; ++uNodeIndex) if (!IsLeaf(uNodeIndex)) return uNodeIndex; return NULL_NEIGHBOR; }
开发者ID:Unode,项目名称:ext_apps,代码行数:7,
示例6: GetIncrementfloat* Node::GetIncrement(){ if(!IsLeaf()) return NULL; else return mpCut->GetIncrement();}
开发者ID:lastfallen,项目名称:mlplus,代码行数:7,
示例7: RemoveTileuint32 RemoveTile(TileGroup* node, Tile* to_delete){ uint32 num_removed = 0; if(IsLeaf(node)) { for(uint8 i = 0; i < node->contained_colliders; ++i) { if(node->colliders[i] == to_delete) { num_removed++; auto remaining = (MAX_LEAF_SIZE - 1) - node->contained_colliders; if(remaining > 0) { memmove(&node->colliders[i], &node->colliders[i + 1], sizeof((uint32)node->colliders[i] * remaining)); node->colliders[i + 1] = 0; } else { node->colliders[i] = 0; // This is the last one in the array } } } } else { TileGroup* child_node = node->child_nodes; for(uint32 i = 0; i < QUADTREE_CHILDREN; ++i) { num_removed += RemoveTile(child_node, to_delete); } } return num_removed;}
开发者ID:ravencgg,项目名称:GLMario,代码行数:35,
示例8: RecalculateBoundingVolumevoid BVHNode<BoundingVolumeType>::Insert(Collider* collider, BoundingVolumeType& volume){ // If we are a leaf node, we need to create two new children and put the new body in one of them if (IsLeaf()) { m_children[0] = new BVHNode<BoundingVolumeType>(this, m_collider, m_volume); m_children[1] = new BVHNode<BoundingVolumeType>(this, collider, volume); m_collider = NULL; // We are no longer a leaf node, so clear our collider RecalculateBoundingVolume(); } // Otherwise, we need to decide which child gets to keep the inserted collider. // We will give it to the child that would grow the least to incorporate it. else { if (m_children[0]->m_volume.GetGrowth(volume) < m_children[1]->m_volume.GetGrowth(volume)) { m_children[0]->Insert(collider, volume); } else { m_children[1]->Insert(collider, volume); } }}
开发者ID:gnleece,项目名称:Dogwood,代码行数:26,
示例9: FindFurthestVisitedItem MenuItem* MenuItem::FindFurthestVisitedItem() { if (IsLeaf() || !subitems[markedSubitemIndex]->IsVisited()) { return this; } else { return subitems[markedSubitemIndex]->FindFurthestVisitedItem(); } }
开发者ID:panmar,项目名称:pg3,代码行数:7,
示例10: inline size_t SpillTree<MetricType, StatisticType, MatType, HyperplaneType, SplitType>::NumPoints() const{ if (IsLeaf()) return count; return 0;}
开发者ID:dasayan05,项目名称:mlpack,代码行数:7,
示例11: TraverseBtoFvoid HQBSPTreeNode::TraverseBtoF(const HQVector4& eye , const HQPlane * frustum , HQPolygonList &listOut)//traverse front to back.<listOut> will store polygons in back to front order. { if (this->boundingBox.Cull(frustum , 6) == HQ_CULLED)//nhánh này hoàn toàn n C++ IsLeapYear函数代码示例 C++ IsKeyPressed函数代码示例
|