当前位置: 首页>>代码示例>>C++>>正文


C++ NodeData::getToken方法代码示例

本文整理汇总了C++中NodeData::getToken方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeData::getToken方法的具体用法?C++ NodeData::getToken怎么用?C++ NodeData::getToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeData的用法示例。


在下文中一共展示了NodeData::getToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: recursiveCopy

/**
 * @brief helper for copy-constructor
 * @details recursively copy nodes from a tree pre-order
 * 
 * @param origNode Node on the original tree to be copied over
 */
void TBST::recursiveCopy(Node* origNode) {
    if(origNode != NULL) { 
        if(origNode->isLeaf()) {
            NodeData* d = origNode->getData();
            insert(d->getToken(), d->getCount());
            d = NULL;
        } else if(!origNode->hasLeftChild()) {
            // 1: have right child, no left child
            // copy the node
            NodeData* d = origNode->getData();
            insert(d->getToken(), d->getCount());
            d = NULL;
            // then recurse down and copy the right child
            recursiveCopy(origNode->getRight());
        } else if(!origNode->hasRightChild()) {
            // 2: have left child, no right child
            NodeData* d = origNode->getData();
            insert(d->getToken(), d->getCount());
            d = NULL;
            // then recurse down and copy the left child
            recursiveCopy(origNode->getLeft());
        } else {
            // 3: have children on both sides
            NodeData* d = origNode->getData();
            insert(d->getToken(), d->getCount());
            d = NULL;
            // then recurse down and copy both children
            recursiveCopy(origNode->getLeft());
            recursiveCopy(origNode->getRight());
        }
    }
}
开发者ID:jamesus95,项目名称:Cpp,代码行数:38,代码来源:tbst.cpp

示例2: testSetters

NodeData testSetters(NodeData& B) {
    NodeData A("a");
    A.decreaseCount();
    assert(A.getCount() == 0);
    
    int bCount = 7;
    while(B.getCount() < bCount) {
        B.increaseCount();
    }
    assert(B.getCount() == bCount);

    assert(A.getToken() < B.getToken());

    A = B;
    assert(A.getToken() == B.getToken());    
    return B;
}
开发者ID:jamesus95,项目名称:Cpp,代码行数:17,代码来源:testData.cpp

示例3: testConstructors

NodeData testConstructors() {
    NodeData A;
    assert(A.getToken() == "");
    assert(A.getCount() == 1);
    NodeData B("hello world");
    assert(B.getToken() == "hello world");
    NodeData C(B);
    assert(C.getToken() == "hello world");
    return B;
}
开发者ID:jamesus95,项目名称:Cpp,代码行数:10,代码来源:testData.cpp

示例4: assert

/** 
 * @brief copy constructor
 * @details creates a copy of the passed in TBST
 * 
 * @param other TBST tree to copy
 */
TBST::TBST(const TBST& other) {
    root = NULL;
    nodeCount = 0;
    if(other.root != NULL) {
        // handle root separately
        assert(root == NULL); // make sure that tree is empty
        // then add the root
        NodeData* rootData = other.root->getData();
        insert(rootData->getToken(), rootData->getCount());

        // recursively copy the left and right subtrees
        recursiveCopy(other.root->getLeft());
        recursiveCopy(other.root->getRight());
    }
    else {
        root = NULL;
    }
}
开发者ID:jamesus95,项目名称:Cpp,代码行数:24,代码来源:tbst.cpp


注:本文中的NodeData::getToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。