SourceForge.jp

stable_priority_queue.h

説明を見る。
00001 #ifndef __STX_STABLE_PRIORITY_QUEUE_H_
00002 #define __STX_STABLE_PRIORITY_QUEUE_H_
00003 
00004 
00005 namespace stx{
00006     
00007 template <class T, class Container = std::deque<T>,
00008           class Compare = std::less<Container::value_type> >
00009 class stable_priority_queue {
00010 public:
00011   typedef Container::value_type value_type;
00012   typedef Container::size_type  size_type;
00013   typedef Container             container_type;
00014 
00015 protected:
00016   Container c;
00017   Compare comp;
00018 
00019 private:
00020   template<class InputIterator>
00021     void push(InputIterator first, InputIterator last)
00022       { for ( ; first != last; ++first ) push(*first); }
00023 
00024 public:
00025   explicit stable_priority_queue(const Compare& pp = Compare(),
00026                                  const Container& cc = Container())
00027     : comp(pp) { push(cc.begin(), cc.end()); }
00028 
00029   template <class InputIterator>
00030     stable_priority_queue(InputIterator first, InputIterator last,
00031                           const Compare& pp = Compare())
00032     : comp(pp) { push(first,last); }
00034   bool              empty() const { return c.empty(); }
00036     size_type         size()  const { return c.size(); }
00038     const value_type& top() const   { return c.back(); }
00040     void              pop()         { c.pop_back(); }
00041     //dequeにぶち込む
00042   void push(const value_type& x) {
00043     c.insert(std::lower_bound(c.begin(), c.end(), x, comp), x);
00044   }
00045 };
00046 
00047 
00048 }//end of stx namespace
00049 
00050 #endif

dkutil 1.02リリース前 d金魚専用マニュアルバージョンに対してSun Dec 28 21:23:08 2003に生成されました。 doxygen 1.3.5