]> git.saurik.com Git - wxWidgets.git/blame - include/wx/stack.h
Overhaul IE zoom functions to support both text and optical zoom.
[wxWidgets.git] / include / wx / stack.h
CommitLineData
3c648a82
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/stack.h
3// Purpose: STL stack clone
b1bf7dc7 4// Author: Lindsay Mathieson, Vadim Zeitlin
3c648a82 5// Created: 30.07.2001
b1bf7dc7
VZ
6// Copyright: (c) 2001 Lindsay Mathieson <lindsay@mathieson.org> (WX_DECLARE_STACK)
7// 2011 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 8// Licence: wxWindows licence
3c648a82
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_STACK_H_
12#define _WX_STACK_H_
13
14#include "wx/vector.h"
15
01871bf6 16#if wxUSE_STD_CONTAINERS
b1bf7dc7
VZ
17
18#include <stack>
19#define wxStack std::stack
20
01871bf6 21#else // !wxUSE_STD_CONTAINERS
b1bf7dc7
VZ
22
23// Notice that unlike std::stack, wxStack currently always uses wxVector and
24// can't be used with any other underlying container type.
25//
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).
28
29template <typename T>
30class wxStack
31{
32public:
33 typedef wxVector<T> container_type;
34 typedef typename container_type::size_type size_type;
35 typedef typename container_type::value_type value_type;
36
37 wxStack() { }
38 explicit wxStack(const container_type& cont) : m_cont(cont) { }
39
40 // Default copy ctor, assignment operator and dtor are ok.
41
42
43 bool empty() const { return m_cont.empty(); }
44 size_type size() const { return m_cont.size(); }
45
46 value_type& top() { return m_cont.back(); }
47 const value_type& top() const { return m_cont.back(); }
48
49 void push(const value_type& val) { m_cont.push_back(val); }
50 void pop() { m_cont.pop_back(); }
51
52private:
53 container_type m_cont;
54};
55
01871bf6 56#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS
b1bf7dc7
VZ
57
58
59// Deprecated macro-based class for compatibility only, don't use any more.
c21ee792
RD
60#define WX_DECLARE_STACK(obj, cls) \
61class cls : public wxVector<obj> \
3c648a82 62{\
3c648a82 63public:\
d775fa82
WS
64 void push(const obj& o)\
65 {\
c21ee792 66 push_back(o); \
d775fa82 67 };\
3c648a82 68\
d775fa82
WS
69 void pop()\
70 {\
c21ee792 71 pop_back(); \
d775fa82 72 };\
3c648a82 73\
d775fa82
WS
74 obj& top()\
75 {\
c21ee792 76 return at(size() - 1);\
d775fa82
WS
77 };\
78 const obj& top() const\
79 {\
c21ee792 80 return at(size() - 1); \
d775fa82 81 };\
3c648a82
VZ
82}
83
84#endif // _WX_STACK_H_
85