|
Member
|
Where defined/TD>
|
#include
#include
#include
#include
#ifdef __STL_USE_NAMESPACES
using __STD::stack;
using __STD::queue;
using __STD::priority_queue;
#endif /* __STL_USE_NAMESPACES */
#endif /* __SGI_STL_STACK_H */
// Local Variables:
// mode:C++
// End:
usr/doc/stl-manual/html/stack.html 100644 0 0 26022 6555204233 15555 0 ustar root root
stack<T, Sequence>
stack<T, Sequence>
 |
 |
 |
|
| Categories: containers, adaptors |
Component type: type |
Description
A stack is an adaptor that provides a restricted subset of
Container functionality: it provides insertion, removal, and
inspection of the element at the top of the stack. Stack is a
"last in first out" (LIFO) data structure: the element at the
top of a stack is the one that was most recently added. [1]
Stack does not allow iteration through its elements. [2]
Stack is a container adaptor, meaning that it is implemented on
top of some underlying container type. By default that underlying
type is deque, but a different type may be selected explicitly.
Example
int main() {
stack<int> S;
S.push(8);
S.push(7);
S.push(4);
assert(S.size() == 3);
assert(S.top() == 4);
S.pop();
assert(S.top() == 7);
S.pop();
assert(S.top() == 8);
S.pop();
assert(S.empty());
}
Definition
Defined in stack.h.
Template parameters
|
Parameter
|
Description
|
Default
|
|
T
|
The type of object stored in the stack.
|
|
|
Sequence
|
The type of the underlying container used to implement the stack.
|
deque<T>
|
Model of
Assignable, Default Constructible
Type requirements
Public base classes
None.
Members
|