Lists, Iterators, Deques, Bad Vector Usage Flashcards
What do you use to traverse a list
an iterator
list <type>::iterator lit;
list <type>::const_iterator lit;</type></type>
A list allows for which insertion and deletion methods
push front, push back
pop front, pop back
To traverse a data structure in reverse order using an iterator you have to use
rbegin and rend
T/F You can insert into vectors, too, but you should not
True. This is due to its run time complexity being O(n^2)
A dequeue stands for a
double ended queue
A dequeue behaves like a vector with the proviso that
you can insert or delete from either end of the dequeue with high efficiency
When should i use a vector?
When you are either simply accessing n elements, or if you are calling only push_back / pop_back
When should i use a dequeue
If you want to call push_front / pop_front in addition to push_back / pop_back
When should i use a list
If you want to insert and delete elements from the middle of the data structure