本文整理汇总了C++中PQueue::bytesUsed方法的典型用法代码示例。如果您正苦于以下问题:C++ PQueue::bytesUsed方法的具体用法?C++ PQueue::bytesUsed怎么用?C++ PQueue::bytesUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PQueue
的用法示例。
在下文中一共展示了PQueue::bytesUsed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunMemoryTrial
/*
* Function: RunMemoryTrial
* ------------------------
* Fills a pqueue to specified size and reports memory usage. Then does
* a bunch of enqueue-dequeue operations to jumble things up and reports
* on the memory usage again. Reports results to cout.
*/
void RunMemoryTrial(int size)
{
PQueue pq;
cout << endl << "Running memory trial on " << size << "-element pqueue" << endl;
for (int i = 0; i < size; i++)
pq.enqueue(RandomInteger(1, size));
cout << "After consecutive enqueues, " << size << "-element pqueue is using "
<< pq.bytesUsed()/1000 << " KB of memory" << endl;
int num = size;
for (int j = 0; j < NumRepetitions; j++) { /* do a bunch of enqueue/dequeue ops */
if (RandomChance(.5)) {
pq.enqueue(RandomInteger(0, size));
num++;
} else {
pq.dequeueMax();
num--;
}
}
cout << "After more enqueue/dequeue, " << num << "-element pqueue is using "
<< pq.bytesUsed()/1000 << " KB of memory" << endl;
}