![]() |
![]() |
![]() |
![]() |
![]() |
|
Using the addElement, firstElement, and
removeElementAt methods, you can represent
first-in, first-out (FIFO) queues with vectors:
*-- firstElement reads elements from the front
|
*-- removeElementAt removes elements from the front
|
v
*---*---*---*---*---*
| | | | | |
*---*---*---*---*---*
^
*-- addElement adds elements at the back
Similarly, you can use vectors to represent last-in, first-out (LIFO) push-down stacks by using the
insertElementAt, firstElement, and removeElementAt
methods:
*-- firstElement reads elements from the front | *-- removeElementAt removes elements from the front | v *---*---*---*---*---* | | | | | | *---*---*---*---*---* ^ *-- insertElementAt adds elements to the front