本文整理汇总了C++中TQueue::top方法的典型用法代码示例。如果您正苦于以下问题:C++ TQueue::top方法的具体用法?C++ TQueue::top怎么用?C++ TQueue::top使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TQueue
的用法示例。
在下文中一共展示了TQueue::top方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OutputQueue
void OutputQueue(TQueue queue)
{
typename TQueue::key_map propertyMap = queue.keys();
// Read out the queue, saving the objects in the order they were in the queue
while(!queue.empty())
{
typename TQueue::value_type queuedObject = queue.top();
std::cout << "queuedObject: " << queuedObject << " ";
typename boost::property_traits<typename TQueue::key_map>::value_type value = get(propertyMap, queuedObject);
std::cout << " value: " << value << std::endl;
queue.pop();
}
}
示例2: levelOrder
void TwoThreeTree::levelOrder() {
if (root == NULL) return;
// Use a tree to do levelOrder Traversal
TQueue queue;
queue.push(root);
root->level = 0;
cout << "Level Order Traversal:\n";
int currentLevel = 0;
while (!queue.isEmpty()) {
const TNode *t = queue.top();
if (t->level != currentLevel) {
cout << endl;
currentLevel = t->level;
}
// push t's children on queue, set their level nubmer
t->print();
if (!t->isLeaf) {
int nextLevel = t->level + 1;
t->left->level = nextLevel;
queue.push(t->left);
t->middle->level = nextLevel;
queue.push(t->middle);
if (t->rlow != -1) {
t->right->level = nextLevel;
queue.push(t->right);
}
}
queue.pop();
}
cout << endl << endl;
}