2
* libpal - Automated Placement of Labels Library
4
* Copyright (C) 2008 Maxence Laurent, MIS-TIC, HEIG-VD
5
* University of Applied Sciences, Western Switzerland
9
* maxence.laurent <at> heig-vd <dot> ch
11
* eric.taillard <at> heig-vd <dot> ch
13
* This file is part of libpal.
15
* libpal is free software: you can redistribute it and/or modify
16
* it under the terms of the GNU General Public License as published by
17
* the Free Software Foundation, either version 3 of the License, or
18
* (at your option) any later version.
20
* libpal is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
* GNU General Public License for more details.
25
* You should have received a copy of the GNU General Public License
26
* along with libpal. If not, see <http://www.gnu.org/licenses/>.
34
#ifndef _PRIORITYQUEUE_H
35
#define _PRIORITYQUEUE_H
39
#define LEFT(x) (2*x+1)
40
#define RIGHT(x) (2*x+2)
41
#define PARENT(x) ((x-1)/2)
57
bool ( *greater )( double l, double r );
60
/** \brief Create a priority queue of max size n
61
* \@param n max size of the queuet
62
* \@param p external vector representing the priority
63
* \@param min best element has the smalest p when min is True ans has the biggest when min is false
65
PriorityQueue( int n, int maxId, bool min );
75
int getBest(); // O(log n)
77
void remove( int key );
78
void insert( int key, double p );
80
void sort(); // O(n log n)
82
void downheap( int id );
83
void upheap( int key );
85
void decreaseKey( int key );
86
void setPriority( int key, double new_p );