1 // This file is part of the ustl library, an STL implementation.
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
9 #ifndef USTACK_H_5242F5635322B2EC44A9AEE73022C6E9
10 #define USTACK_H_5242F5635322B2EC44A9AEE73022C6E9
14 /// \class stack ustack.h ustl.h
15 /// \ingroup Sequences
17 /// \brief Stack adapter to uSTL containers.
19 template <typename Sequence
>
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
;
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()); }
40 Sequence m_Storage
; ///< Where the data actually is.