- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Blis-0.91.2/Alps/src/AlpsPriorityQueue.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the Abstract Library for Parallel Search (ALPS).     *
    00003  *                                                                           *
    00004  * ALPS is distributed under the Common Public License as part of the        *
    00005  * COIN-OR repository (http://www.coin-or.org).                              *
    00006  *                                                                           *
    00007  * Authors:                                                                  *
    00008  *                                                                           *
    00009  *          Yan Xu, Lehigh University                                        *
    00010  *          Ted Ralphs, Lehigh University                                    *
    00011  *                                                                           *
    00012  * Conceptual Design:                                                        *
    00013  *                                                                           *
    00014  *          Yan Xu, Lehigh University                                        *
    00015  *          Ted Ralphs, Lehigh University                                    *
    00016  *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
    00017  *          Matthew Saltzman, Clemson University                             *
    00018  *                                                                           *
    00019  *                                                                           *
    00020  * Copyright (C) 2001-2009, Lehigh University, Yan Xu, and Ted Ralphs.       *
    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_; // Sort function for heap ordering.
    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   // void cleanQueue(double cutoff){};
    00100 };
    00101
    00102 #endif
    00103
    00104 #endif  // FILE