From 47655422e0d7bc14aa83e5268f6fa0a01a8b2d5e Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 25 Nov 2015 19:25:40 -0800 Subject: [PATCH] Stub alternative (vector) implementation of Stack. --- Stack.hpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Stack.hpp b/Stack.hpp index c04afb1..3f82078 100644 --- a/Stack.hpp +++ b/Stack.hpp @@ -24,6 +24,63 @@ namespace cy { +#if 0 +template +class stack { + public: + typedef std::vector Data_; + typedef typename Data_::const_reverse_iterator const_iterator; + + private: + Data_ data_; + + public: + stack() { + data_.reserve(200); + } + + _finline Type_ &operator [](size_t i) { + return data_[data_.size() - 1 - i]; + } + + _finline const Type_ &operator [](size_t i) const { + return data_[data_.size() - 1 - i]; + } + + _finline void push(Type_ &t) { + data_.push_back(t); + } + + _finline void pop() { + data_.pop_back(); + } + + _finline void pop(unsigned int size) { + for (; size != 0; --size) + pop(); + } + + void clear() { + data_.clear(); + } + + _finline size_t size() const { + return data_.size(); + } + + _finline const_iterator begin() const { + return data_.rbegin(); + } + + _finline const_iterator end() const { + return data_.rend(); + } + + private: + stack(const stack &); + stack &operator =(const stack &); +}; +#else template class stack { public: @@ -120,6 +177,7 @@ class stack { stack(const stack &); stack &operator =(const stack &); }; +#endif template > class slice { -- 2.50.0