开发者

Queue implementation with heap

开发者 https://www.devze.com 2023-02-18 04:00 出处:网络
I\'m trying to implement a queue. This is my framework class Queue { HANDLE heap; Int *buf; Int head, tail;

I'm trying to implement a queue.

This is my framework

class Queue { 
 HANDLE heap;    
 Int *buf;     
 Int head, tail;   
 Int spaceAllocated;  
 Int sizeQ;    
public: 
 void Push (Int item);    
 Int Pop (Int *array, int batchSize);  
}

I'm doing this with a heap using windows API. What is the purpose of the buffer and how is it used? I know it has something to 开发者_如何学Godo with the heap and holding memory.


*Buf is the actual memory pointer you'll use to store your items. I imagine you're using VirtualAlloc() here to create your buffer? If so, you need to know the maximum size of your queue.

As an aside, why can you not use the STL queue?

0

精彩评论

暂无评论...
验证码 换一张
取 消