Runtime complexity of STL Stack
Stack
In the C++ STL, a stack is a
container adaptor.
That means there is no primitive stack data structure. Instead,
you create a stack from another container, like a list, and the stack's basic operations will be implemented
using the underlying container's operations.
Header
#include <stack>
Constructors
stack< container<T> > s;
|
Make an empty stack.
|
O(1)
|
Accessors
s.top();
|
Return the top element.
|
O(1)
|
s.size();
|
Return current number of elements.
|
O(1)
|
s.empty();
|
Return true if stack is empty.
|
O(1)
|
Modifiers
s.push(value);
|
Push value on top.
|
Same as push_back() for underlying container.
|
s.pop();
|
Pop value from top.
|
O(1)
|
No comments:
Post a Comment