interface of prior. queue

V

vaclavpich

Hi all,
I needed a priority queue but I couldn't use stl. So I wrote my
priority queue. But I'm not sure that my implementation is good. I
want to know your opinion :

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1)
template<
class _Ty,
class CPriorityQueuePolicy
{
_Container c;
public:
// common interface :
_Ty& top();
void push(const _Ty&);
void pop();
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2)
template<
class _Ty,
class CPushPopPolicy : protected CPriorityQueuePolicy<_Ty,
_Predicate, _Container >
{
typedef CPriorityQueuePolicy<_Ty, _Predicate, _Container > base;
public:
// common interface :
void push(const _Ty& val){
base::push(val);
}
_Ty pop(){
_Ty val = base::top();
base::pop();
return val;
}
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// priority queue :
template<
class _Ty,
class _Predicate = Less<_Ty>, // comparator
class _Container = Array<_Ty> // like std::vector
class CPriorityQueue : public _Policy<_Ty, _Predicate, _Container> {};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I want to have 2 kinds of priority queue and I can choose the best
interface.
I'm not sure that people can easily use my priority queue.

If you have better idea how to write it please tell me. Or write only
your opinion.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top