00001
00002 00004
00005 #if !defined(AFX_PRIORITYQUEUE_H__34D82301_A1F5_45A7_A519_566379E66DB4__INCLUDED_)
00006 #define AFX_PRIORITYQUEUE_H__34D82301_A1F5_45A7_A519_566379E66DB4__INCLUDED_
00007
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011
00012 #include "Queue.h"
00027 class CPriorityQueue : public CQueue
00028 {
00029 class PriorPix {
00030 public:
00031 LPPIXEL p;
00032 short parity;
00033 };
00034 class PixGreater {
00035 public:
00036 bool operator()(PriorPix p1, PriorPix p2) const {return *(p1.p)>*(p2.p); }
00037 };
00038 priority_queue<PriorPix, vector<PriorPix>, PixGreater > pqueue;
00039
00040 public:
00041 CPriorityQueue() {
00042 };
00043 virtual ~CPriorityQueue() {
00044 while (!pqueue.empty()) {
00045 pqueue.pop();
00046 }
00047 };
00048
00049 inline bool empty() {
00050 return (pqueue.empty());
00051 };
00052 inline void first(LPPIXEL *p) {
00053 PriorPix pp = pqueue.top();
00054 *p = pp.p;
00055 pqueue.pop();
00056 };
00057 inline void first(LPPIXEL *p, short *parity) {
00058 PriorPix pp = pqueue.top();
00059 *p = pp.p;
00060 *parity = pp.parity;
00061 pqueue.pop();
00062 };
00063 inline void add(LPPIXEL p) {
00064 PriorPix pp;
00065 pp.p = p;
00066 pp.parity = 0;
00067 pqueue.push(pp);
00068 };
00069 inline void add(LPPIXEL p, short parity) {
00070 PriorPix pp;
00071 pp.p = p;
00072 pp.parity = parity;
00073 pqueue.push(pp);
00074 };
00075 inline void invert() {
00076
00077 };
00078 };
00079
00080 #endif // !defined(AFX_PRIORITYQUEUE_H__34D82301_A1F5_45A7_A519_566379E66DB4__INCLUDED_)