Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:59

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_CONTAINER_STACK_HPP
0012 #define BOOST_COMPUTE_CONTAINER_STACK_HPP
0013 
0014 #include <boost/compute/container/vector.hpp>
0015 
0016 namespace boost {
0017 namespace compute {
0018 
0019 template<class T>
0020 class stack
0021 {
0022 public:
0023     typedef vector<T> container_type;
0024     typedef typename container_type::size_type size_type;
0025     typedef typename container_type::value_type value_type;
0026 
0027     stack()
0028     {
0029     }
0030 
0031     stack(const stack<T> &other)
0032         : m_vector(other.m_vector)
0033     {
0034     }
0035 
0036     stack<T>& operator=(const stack<T> &other)
0037     {
0038         if(this != &other){
0039             m_vector = other.m_vector;
0040         }
0041 
0042         return *this;
0043     }
0044 
0045     ~stack()
0046     {
0047     }
0048 
0049     bool empty() const
0050     {
0051         return m_vector.empty();
0052     }
0053 
0054     size_type size() const
0055     {
0056         return m_vector.size();
0057     }
0058 
0059     value_type top() const
0060     {
0061         return m_vector.back();
0062     }
0063 
0064     void push(const T &value)
0065     {
0066         m_vector.push_back(value);
0067     }
0068 
0069     void pop()
0070     {
0071         m_vector.pop_back();
0072     }
0073 
0074 private:
0075     container_type m_vector;
0076 };
0077 
0078 } // end compute namespace
0079 } // end boost namespace
0080 
0081 #endif // BOOST_COMPUTE_CONTAINER_STACK_HPP