本文整理汇总了C++中Heap::Enqueue方法的典型用法代码示例。如果您正苦于以下问题:C++ Heap::Enqueue方法的具体用法?C++ Heap::Enqueue怎么用?C++ Heap::Enqueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Heap
的用法示例。
在下文中一共展示了Heap::Enqueue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Heap *theHeap = new Heap(10); // Create a heap of the default size
cout << "Building the heap and adding items\n\n";
// Add some items
theHeap->Enqueue(123, 1.23);
theHeap->Enqueue(345, 3.45);
theHeap->Enqueue(234, 2.34);
theHeap->Enqueue(678, 6.78);
theHeap->Enqueue(456, 4.56);
theHeap->Enqueue(567, 5.67);
theHeap->Enqueue(789, 7.89);
// This will build a heap that looks like this
// 789
// / \
// 456 678
// / \ / \
// 123 345 234 567
// See what we got
cout << "Elements in the heap.\n";
theHeap->printAll();
cout << "Dequeuing items from the heap.\n\n";
/* Heap temp = theHeap.>Dequeue();
while((temp) != NULL)
{
cout << "Dequeueing " << temp->getKey() << endl;
delete temp; // delete this one
// See what we have left
cout << "Elements in the heap.\n";
theHeap->printAll();
cout << endl;
}*/
}