Build system improvements
[ustl.git] / ustack.h
blobc48e3b3645ad225d69ffcbc9df805a804c36bd5d
1 // This file is part of the ustl library, an STL implementation.
2 //
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
5 //
6 // ustack.h
7 //
9 #ifndef USTACK_H_5242F5635322B2EC44A9AEE73022C6E9
10 #define USTACK_H_5242F5635322B2EC44A9AEE73022C6E9
12 namespace ustl {
14 /// \class stack ustack.h ustl.h
15 /// \ingroup Sequences
16 ///
17 /// \brief Stack adapter to uSTL containers.
18 ///
19 template <typename Sequence>
20 class stack {
21 public:
22 typedef typename Sequence::value_type value_type;
23 typedef typename Sequence::size_type size_type;
24 typedef typename Sequence::difference_type difference_type;
25 typedef typename Sequence::reference reference;
26 typedef typename Sequence::const_reference const_reference;
27 typedef typename Sequence::pointer pointer;
28 public:
29 inline stack (void) : m_Storage () { }
30 explicit inline stack (const Sequence& s) : m_Storage (s) { }
31 inline bool empty (void) const { return (m_Storage.empty()); }
32 inline size_type size (void) const { return (m_Storage.size()); }
33 inline reference top (void) { return (m_Storage.back()); }
34 inline const_reference top (void) const { return (m_Storage.back()); }
35 inline void push (const value_type& v) { m_Storage.push_back (v); }
36 inline void pop (void) { m_Storage.pop_back(); }
37 inline bool operator== (const stack& s) { return (m_Storage == s.m_Storage); }
38 inline bool operator< (const stack& s) { return (m_Storage.size() < s.m_Storage.size()); }
39 private:
40 Sequence m_Storage; ///< Where the data actually is.
43 } // namespace ustl
45 #endif