473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

interface of prior. queue

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 _Predicate = Less<_Ty>, // comparator
class _Container = Array<_Ty // like std::vector
>
class CPriorityQueuePolicy
{
_Container c;
public:
// common interface :
_Ty& top();
void push(const _Ty&);
void pop();
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2)
template<
class _Ty,
class _Predicate = Less<_Ty>, // comparator
class _Container = Array<_Ty // like std::vector
>
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
template <class, class, class >class _Policy =
CPriorityQueuePolicy<_Ty, _Predicate, _Container >
>
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.

Oct 26 '08 #1
0 1225

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: scott.manton | last post by:
I'm a new user of the Python C interface. I would like to know if it is possible to put items on a standard python Queue object in C, and pop them from Python. Does the Python/C interface...
3
by: Sai Kit Tong | last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't make it clear in my original mail. I got a couple of answers but none of them address my issues directly (See attached...
7
by: Hazz | last post by:
Are there any good references/articles/books which provide clarity toward my insecurity still on deciding how to model a complex system? I still feel uncomfortable with my understanding, even...
0
by: Mark | last post by:
I create a simple interface in a com object: public interface ISimple { void a(); int b(); } I build the object in Visual Studio and load the object from Excel. I can call a and b...
6
by: Patrick | last post by:
Environment: Windows 2000 Server SP4, IIS5.0, Dot Net Framework 1.1 Situation: A Console application that send an email using System.Web.Mail.MailMessage Observation: 1) Recently, the...
6
by: Ricky W. Hunt | last post by:
It's dawning on my a lot of my problems with VB.NET is I'm still approaching it in the same way I've programmed since the late 70's. I've always been very structured, flow-charted everything, used...
7
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I...
1
by: Paul Rubin | last post by:
Is there any reason Queue shouldn't have an iterator interface? I.e. instead of while True: item = work_queue.get() if item is quit_sentinel: # put sentinel back so other readers can find it...
8
by: rn5a | last post by:
Suppose I have the following class code: Imports System Imports System.Data Imports System.Data.SqlClient Public Class DBSettings Private sqlCmd As SqlCommand Private sqlConn As...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.