Member Function | Stack | Queue | Deque |
---|---|---|---|
push(element) | Inserts element at top | Inserts element at back | Inserts element at front or back |
pop() | Removes top element | Removes front element | Removes front or back element |
top() | Returns top element | N/A | Returns front element or back element |
empty() | Checks if stack is empty | Checks if queue is empty | Checks if deque is empty |
size() | Returns size of stack | Returns size of queue | Returns size of deque |
front() | N/A | Returns front element | Returns front element |
back() | N/A | N/A | Returns last element |
while(size–) 循环size次,while(–size)循环size-1次