473,569 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 CPriorityQueueP olicy
{
_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 CPriorityQueueP olicy<_Ty,
_Predicate, _Container >
{
typedef CPriorityQueueP olicy<_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 =
CPriorityQueueP olicy<_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 1231

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

Similar topics

1
2006
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 support Queue objects? A little background. I made a C dll that sets up a thread for collecting data from an NI data aquisition card. The thread...
3
2361
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 response). My first reply directed me to source code migration but I didn't have the source code. The second reply mentioned about .NET interoperability...
7
12863
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 though I have worked with these systems on when to decide to use interfaces (and how they should be developed) as opposed to or complemented by the use...
0
1052
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 without any problems.
6
2410
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 application is failing to deliver messages! 2) Even when eMails was delivered, there are no entries logged in the SMTP Log files! 3) I have carried out...
6
1932
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 subroutines, etc. Now I'm trying to study this new way and I'm getting some terms confused and can find no clear definition (some even overlap or...
7
2086
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 just make a Sub Dispose() and the CLR will know that this is the Dispose method to call when the object falls out of scope? Thanks.
1
4494
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 work_queue.put(quit_sentinel) break process(item)
8
2073
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 SqlConnection Public ConnectionString As String
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.