-
Notifications
You must be signed in to change notification settings - Fork 0
/
PQueue.h
50 lines (41 loc) · 1.11 KB
/
PQueue.h
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
/*
* PQueue.h
*
* Created on: 23 de Fev de 2013
* Author: fahrenheit
*/
#ifndef SKELTRACK_PQUEUE_H_
#define SKELTRACK_PQUEUE_H_
#include <cstdlib>
#include <cmath>
#include <vector>
#include "Util.h"
#include "Node.h"
#include "PQelement.h"
namespace Skeltrack {
class PQueue {
public:
PQueue(unsigned int max_size, unsigned int width, unsigned int height);
virtual ~PQueue();
virtual void insert(Node * data, int priority);
virtual Node * pop_minimum(void);
virtual unsigned int size(void) { return _size; }
virtual Node * top(void) { return pop_minimum(); }
virtual void remove(Node * node);
virtual bool has_element(Node * element);
virtual bool empty(void) { return _size == 0; };
protected:
std::vector<int> *map;
std::vector<PQelement *> * elements;
unsigned int _size;
unsigned int max_size;
unsigned int width;
unsigned int height;
unsigned int indexOf(Node * element);
void swap (unsigned int a, unsigned int b);
bool greater (unsigned int a, unsigned int b);
void swim (unsigned int index);
void sink (unsigned int index);
};
} /* namespace Skeltrack */
#endif /* SKELTRACK_PQUEUE_H_ */