-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpqueue.h
More file actions
55 lines (47 loc) · 1.2 KB
/
pqueue.h
File metadata and controls
55 lines (47 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef _PQUEUE_H_
#define _PQUEUE_H_
#include <stdio.h>
using namespace std;
////////////////////////////////////////////////////////////////////////////////
//
// PQUEUE
//
////////////////////////////////////////////////////////////////////////////////
class PQDATUM
{
private:
int _node;
double _dist;
public:
PQDATUM() { _node = -1; _dist = -1; }
~PQDATUM() {}
int node() { return _node; }
double dist() { return _dist; }
void set_node(int node) { _node = node; }
void set_dist(double dist) { _dist = dist; }
};
class PQUEUE
{
private:
int _size, _avail, _step;
PQDATUM *_d;
public:
PQUEUE() { _size = -1; _avail = -1; _step = -1; }
~PQUEUE() {}
int size() { return _size; }
int avail() { return _avail; }
int step() { return _step; }
PQDATUM *d() { return _d; }
PQUEUE *pqinit(int n);
int pqinsert( PQDATUM a_d, int *pos);
PQDATUM *pqremove( PQDATUM *a_d, int *pos);
int pqdeckey( PQDATUM a_d, int *pos);
PQDATUM *pqpeek( PQDATUM *a_d);
double get_distance( PQDATUM d) { return ( d.dist()); }
int pqempty() { return ( _size == 1); }
void pqfree( int *pos) {
free( _d);
free( pos);
}
};
#endif