Home | Projects | Notes > C++ Programming > Stacks
xxxxxxxxxx
11
Core Interface
Operation | Effect |
---|---|
push() | Inserts an element into the stack |
top() | Returns the next element in the stack (does not remove it) |
pop() | Removes an element from the stack (does not return it) |
size() | Returns the current number of elements |
empty() | Returns whether the stack is empty (equivalent to size()==0 ) |
Calling
top()
andpop()
for an empty stack always results in undefined behavior. The member functionssize()
andempty()
are provided to check whether the stack contains elements.