00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef AlpsPriorityQueue_h_
00024 #define AlpsPriorityQueue_h_
00025
00026 #include <queue>
00027 #include <vector>
00028 #include "CoinHelperFunctions.hpp"
00029 #include "AlpsSearchStrategyBase.h"
00030
00031
00032
00033 template<class T>
00034 class AlpsPriorityQueue {
00035 private:
00036 AlpsPriorityQueue(const AlpsPriorityQueue&);
00037 AlpsPriorityQueue& operator=(const AlpsPriorityQueue&);
00038
00039 private:
00040 std::vector<T> vec_;
00041 AlpsCompare<T> comparison_;
00042
00043 public:
00044 AlpsPriorityQueue() {}
00045 AlpsPriorityQueue(AlpsSearchStrategy<T>& compare) {
00046 setComparison(compare);
00047 }
00048
00050 const std::vector<T>& getContainer() const { return vec_; }
00051
00053 void setComparison(AlpsSearchStrategy<T>& c) {
00054 comparison_.strategy_ = &c;
00055 std::make_heap(vec_.begin(), vec_.end(), comparison_);
00056 }
00057
00059 T top() const { return vec_.front(); }
00060
00062 void push(T x) {
00063 vec_.push_back(x);
00064 std::push_heap(vec_.begin(), vec_.end(), comparison_);
00065 }
00066
00068 void pop() {
00069 std::pop_heap(vec_.begin(), vec_.end(), comparison_);
00070 vec_.pop_back();
00071 }
00072
00074 bool empty() const{
00075 return vec_.empty();
00076 }
00077
00079 size_t size() const {
00080 return vec_.size();
00081 }
00082
00084 void clear() { vec_.clear(); }
00085 };
00086
00087
00088
00089 #if 0
00090 template<class T,
00091 class Container = std::vector<T>,
00092 class Compare = std::less<typename Container::value_type> >
00093 class AlpsPriorityQueue : public std::priority_queue<T, Container, Compare> {
00094 public:
00096 const Container& getContainer() const { return c; }
00097
00099
00100 };
00101
00102 #endif
00103
00104 #endif // FILE