n-Dimensional Fast Methods  0.7
 All Classes Functions Variables Typedefs Pages
fmpriorityqueue.hpp
1 
20 #ifndef FMPRIORITYQUEUE_H_
21 #define FMPRIORITYQUEUE_H_
22 
23 #include <boost/heap/priority_queue.hpp>
24 
25 #include <fast_methods/datastructures/fmcompare.hpp>
26 
27 template <class cell_t = FMCell> class FMPriorityQueue{
28 
29  public:
30  FMPriorityQueue () {}
31 
33  FMPriorityQueue (const int & n) { heap_.reserve(n); }
34 
35  virtual ~ FMPriorityQueue() {}
36 
38  void setMaxSize
39  (const int & n) {
40  heap_.reserve(n);
41  }
42 
44  void push
45  (const cell_t * c) {
46  heap_.push(c);
47  }
48 
51  void increase
52  (const cell_t * c) {
53  heap_.push(c);
54  }
55 
57  int popMinIdx
58  () {
59  const int idx = heap_.top()->getIndex();
60  heap_.pop();
61  return idx;
62  }
63 
65  size_t size
66  () const {
67  return heap_.size();
68  }
69 
71  void clear
72  () {
73  heap_.clear();
74  }
75 
77  bool empty
78  () const {
79  return heap_.empty();
80  }
81 
82  protected:
84  boost::heap::priority_queue<const cell_t *, boost::heap::compare<FMCompare<cell_t> > > heap_;
85 };
86 
87 
88 #endif /* FMPRIORITYQUEUE_H_ */
void clear()
Deallocates heap memory.
Wrap for the Boost Priority Queue class to be used in the FM algorithms. Ready to be used with FMCell...
size_t size() const
Returns current size of the heap.
bool empty() const
Returns true if the heap is empty.
void setMaxSize(const int &n)
Sets the maximum number of cells the heap will contain.
FMPriorityQueue(const int &n)
Shorthand for heap element handle type.
boost::heap::priority_queue< const cell_t *, boost::heap::compare< FMCompare< cell_t > > > heap_
The actual queue for FMCells.
void increase(const cell_t *c)
Priority queues do not allow key increasing. Therefore, it pushes the element again. This is done so that SFMM is implemented as FMM with this heap.
void push(const cell_t *c)
Pushes a new element into the heap.
int popMinIdx()
Pops index of the element with lowest value and removes it from the heap.