本文整理汇总了C++中BSTNode::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ BSTNode::getValue方法的具体用法?C++ BSTNode::getValue怎么用?C++ BSTNode::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSTNode
的用法示例。
在下文中一共展示了BSTNode::getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: breadthFirstTraversal
int BinarySearchTree :: breadthFirstTraversal (int number) const {
Queue queue;
BSTNode* current = root;
queue.add(root);
int count = 0;
while (current != NULL) {
//If there is right child, add it to queue
if (current -> getLeft() != 0)
queue.add(current -> getLeft());
//If there is right child, add it to queue
if (current -> getRight() != 0)
queue.add(current -> getRight());
queue.removeFromHead(current);
if (current->getValue() == number) {
return count;
}
current = getBSTNodeFromQueue(queue);
count++;
}
return count;
}// end breadthFirstTraversal
示例2: print
void UnorderedLinkedList :: print () const {
// cout<< "(" << ((left == 0)?0:left -> getValue()) <<")";
// cout<<value;
// cout<< "(" << ((right == 0)?0:right -> getValue())<<")";
// cout<<endl;
if (head != 0) {
BSTNode *nodeHead = head -> getValue ();
cout<< "Head -->" << ((head == 0)?0:nodeHead->getValue());
}
cout<<endl;
if (tail != 0) {
BSTNode *nodeTail = tail -> getValue ();
cout<< "Tail -->" << ((tail == 0)?0:nodeTail->getValue());
}
cout<<endl;
}//end print