]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/stack.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: STL stack clone
4 // Author: Lindsay Mathieson, Vadim Zeitlin
6 // Copyright: (c) 2001 Lindsay Mathieson <lindsay@mathieson.org> (WX_DECLARE_STACK)
7 // 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
14 #include "wx/vector.h"
19 #define wxStack std::stack
23 // Notice that unlike std::stack, wxStack currently always uses wxVector and
24 // can't be used with any other underlying container type.
26 // Another difference is that comparison operators between stacks are not
27 // implemented (but they should be, see 23.2.3.3 of ISO/IEC 14882:1998).
33 typedef wxVector
<T
> container_type
;
34 typedef typename
container_type::size_type size_type
;
35 typedef typename
container_type::value_type value_type
;
38 explicit wxStack(const container_type
& cont
) : m_cont(cont
) { }
40 // Default copy ctor, assignment operator and dtor are ok.
43 bool empty() const { return m_cont
.empty(); }
44 size_type
size() const { return m_cont
.size(); }
46 value_type
& top() { return m_cont
.back(); }
47 const value_type
& top() const { return m_cont
.back(); }
49 void push(const value_type
& val
) { m_cont
.push_back(val
); }
50 void pop() { m_cont
.pop_back(); }
53 container_type m_cont
;
56 #endif // wxUSE_STL/!wxUSE_STL
59 // Deprecated macro-based class for compatibility only, don't use any more.
60 #define WX_DECLARE_STACK(obj, cls) \
61 class cls : public wxVector<obj> \
64 void push(const obj& o)\
76 return at(size() - 1);\
78 const obj& top() const\
80 return at(size() - 1); \
84 #endif // _WX_STACK_H_