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