click below
click below
Normal Size Small Size show me how
C++-ContainerAdapter
| Question | Answer |
|---|---|
| Container adapter | A container that provides a defined interface. |
| Stacks | Data structure that operated on a lifo queue. |
| Stack/Queue.push() | Adds item to the top of the stack or back of a queue |
| Stack/Queue.size | Returns stack size |
| Stack/Queue.empty | Returns true if empty |
| Iterating through a stack or queue by index-syntax | Can iterate by index to size int size = container.size(); //stack size changes in loop if pop() is used so initialize outside for (int i = 0; i < size; i++) {} |
| Stack.top() | Returns a reference to the top element of the stack |
| Queue/Stack.pop() (write out) | Removes the top element of the stack or the front element of the queue |
| Queue | 1. Adaptive container Operates fifo. |
| Priority queue-description | A queue ranked by value with first element being greatest by some strict criteria. |
| Queue.front() | Returns a reference to the oldest (e.g. next up) element |
| ContainerAdapter instantiation syntax | std::ContainerType<vartype> name; |
| Container adapter-examples | Includes stacks, queues, priority queues |
| Add an item to the end of a queue-syntax | Queue.push(value to be added) |