n-Dimensional Fast Methods  0.7
 All Classes Functions Variables Typedefs Pages
fmuntidyqueue.hpp
1 
20 #ifndef FMUNTIDYQUEUE_HPP_
21 #define FMUNTIDYQUEUE_HPP_
22 
23 #include <fast_methods/thirdparty/untidy_queue.hpp>
24 #include <fast_methods/ndgridmap/fmcell.h>
25 
27 template<class cell_t = FMCell> class FMUntidyQueue {
28 
29  public:
32  (unsigned s = 1000, double inc = 2) {
33  queue_ = new levelset::PriorityQueue<const cell_t * >(s, inc);
34  }
35 
36  virtual ~FMUntidyQueue() { delete queue_; }
37 
39  void push
40  (cell_t * c) {
41  c->setBucket( queue_->push(c, c->getArrivalTime()) );
42  }
43 
45  size_t size
46  () const {
47  return queue_->size();
48  }
49 
52  void increase
53  (cell_t * c) {
54  c->setBucket( queue_->increase_priority(c, c->getBucket(), c->getArrivalTime()) );
55  }
56 
58  unsigned int topIdx
59  (){
60  return queue_->top()->getIndex();
61  }
62 
64  void pop
65  () {
66  queue_->pop();
67  }
68 
70  void clear
71  () {
72  queue_->clear();
73  }
74 
76  bool empty
77  () const {
78  return queue_->empty();
79  }
80 
81  protected:
83  levelset::PriorityQueue<const cell_t * > * queue_;
84 };
85 
86 #endif /* FMUNTIDYQUEUE_H_ */
void push(cell_t *c)
Pushes a new element into the heap.
size_t size() const
Returns current size of the heap.
FMUntidyQueue(unsigned s=1000, double inc=2)
Creates an object with s buckets of size s.
Wraps the UntidyQueue implementation by Jerome Piovano
void increase(cell_t *c)
Updates the position of the cell in the priority queue. Its priority can only increase. Also updates the bucket of the cell.
void pop()
Removes the top value of the heap.
bool empty() const
Returns true if the heap is empty.
levelset::PriorityQueue< const cell_t * > * queue_
The actual Unitidy queue for cell_t.
void clear()
Deallocates heap memory.
unsigned int topIdx()
Returns index of the element with lowest value (to be popped next).