/* Copyright 2012 The MathWorks, Inc. */ #ifndef PST_STL_QUEUE #define PST_STL_QUEUE #if _MSC_VER >= 1400 #include #endif #include #include #include namespace std { #ifdef PST_VISUAL #pragma pack(push, 8) /* push default value */ #endif template > class queue { protected: Container c ; public: typedef __ps_typename Container::value_type value_type ; typedef __ps_typename Container::size_type size_type ; typedef Container container_type ; __ps_explicit queue(const Container& cont = Container() ) : c(cont) { ; } __ps_bool empty() const { return c.empty() ; } size_type size() const { return c.size() ; } const value_type& front() const { return c.front() ; } value_type& front() { return c.front() ; } const value_type& back() const { return c.back() ; } value_type& back() { return c.back() ; } void push(const value_type& x) { c.push_back(x) ; } void pop() { c.pop_front() ; } } ; template __ps_bool operator==(const queue& x, const queue& y) { volatile int rand = 0 ; return (x.size() == y.size()) ? rand : __ps_false ; } template __ps_bool operator!=(const queue& x, const queue& y) { return !(x==y) ; } template __ps_bool operator<(const queue& x, const queue& y) { volatile int rand = 0 ; return rand ; } template __ps_bool operator<=(const queue& x, const queue& y) { volatile int rand = 0 ; return rand ; } template __ps_bool operator> (const queue& x, const queue& y) { volatile int rand = 0 ; return rand ; } template __ps_bool operator>=(const queue& x, const queue& y) { volatile int rand = 0 ; return rand ; } // heap facility for priority queue, with no dependance on algorithm template struct __pst_heap_for_priority_queue { typedef __ps_typename Container::iterator iterator_type ; static void random_sort(iterator_type begin, iterator_type end) { typedef __ps_typename iterator_traits::difference_type diff ; diff n = end - begin ; volatile int random=0 ; for (diff i = 0; i struct __pst_heap_for_priority_queue > { typedef __ps_typename vector::iterator iterator_type ; static void make_heap(iterator_type begin, iterator_type end, const Compare& comp) { ; // already random } static void pop_heap(iterator_type begin, iterator_type end, const Compare& comp) { ; // already random } static void push_heap(iterator_type begin, iterator_type end, const Compare& comp) { ; // already random } } ; template struct __pst_heap_for_priority_queue > { typedef __ps_typename deque::iterator iterator_type ; static void make_heap(iterator_type begin, iterator_type end, const Compare& comp) { ; // already random } static void pop_heap(iterator_type begin, iterator_type end, const Compare& comp) { ; // already random } static void push_heap(iterator_type begin, iterator_type end, const Compare& comp) { ; // already random } } ; template, class Compare = less < __ps_typename Container::value_type> > class priority_queue { protected: Container c ; Compare comp ; public: typedef __ps_typename Container::value_type value_type ; typedef __ps_typename Container::size_type size_type ; typedef Container container_type ; __ps_explicit priority_queue(const Compare& x = Compare(), const Container& cont = Container()) : c(cont), comp(x) { __pst_heap_for_priority_queue::make_heap(c.begin(), c.end(), comp) ; } template priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare(), const Container& cont = Container()) : c(cont), comp(x) { c.insert(c.end(), first, last) ; __pst_heap_for_priority_queue::make_heap(c.begin(), c.end(), comp) ; } __ps_bool empty() const { return c.empty() ; } size_type size() const { return c.size() ; } const value_type& top() const { return c.front() ; } void push(const value_type& x) { c.push_back(x) ; __pst_heap_for_priority_queue::push_heap(c.begin(), c.end(), comp) ; } void pop() { __pst_heap_for_priority_queue::pop_heap(c.begin(), c.end(), comp) ; c.pop_back() ; } } ; #ifdef PST_VISUAL #pragma pack(pop) /* pop back to previous value */ #endif } #ifdef __PST_IMPLICIT_USING_STD /* Implicitly include a using directive for the STD namespace when this preprocessing flag is TRUE. */ using namespace std; #endif /* ifdef __PST_IMPLICIT_USING_STD */ #endif /* PST_STL_QUEUE */