]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/stack.h
put both versions of wxGetMousePosition in one place so they can use one implementation
[wxWidgets.git] / interface / wx / stack.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/stack.h
3 // Purpose: interface of wxStack<T>
4 // Author: Vadim Zeitlin
5 // RCS-ID: $Id$
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 /**
11 wxStack<T> is similar to @c std::stack and can be used exactly like it.
12
13 If wxWidgets is compiled in STL mode, wxStack will just be a typedef to
14 @c std::stack but the advantage of this class is that it is also available
15 on the (rare) platforms where STL is not, so using it makes the code
16 marginally more portable. If you only target the standard desktop
17 platforms, please always use @c std::stack directly instead.
18
19 The main difference of this class compared to the standard version is that
20 it always uses wxVector<T> as the underlying container and doesn't allow
21 specifying an alternative container type. Another missing part is that the
22 comparison operators between wxStacks are not currently implemented. Other
23 than that, this class is exactly the same as @c std::stack, so please refer
24 to the STL documentation for further information.
25
26 @nolibrary
27 @category{containers}
28
29 @see @ref overview_container, wxVector<T>
30
31 @since 2.9.2
32 */
33 template <typename T>
34 class wxStack<T>
35 {
36 public:
37 /// Type of the underlying container used.
38 typedef wxVector<T> container_type;
39
40 /// Type returned by size() method.
41 typedef typename container_type::size_type size_type;
42
43 /// Type of the elements stored in the stack.
44 typedef typename container_type::value_type value_type;
45
46
47 /**
48 Stack can be created either empty or initialized with the contents of
49 an existing compatible container.
50 */
51 //@{
52 wxStack();
53 explicit wxStack(const container_type& cont);
54 //@}
55
56 /// Return whether the stack is currently empty.
57 bool empty() const;
58
59 /// Return the number of elements in the stack.
60 size_type size() const;
61
62 /**
63 Return the element on top of the stack.
64 */
65 //@{
66 value_type& top();
67 const value_type& top();
68 //@}
69
70 /// Adds an element to the stack.
71 void push(const value_type& val);
72
73 /// Removes the element currently on top of the stack.
74 void pop();
75 };