So I am writing a graph traversal routine and I would like to be able to turn it into either depth-first or breadth-first traversal by choosing a FIFO or a LIFO neighbor traversal policy. In practice this means that I need to abstract "enqueue" and "dequeue" operations over std::deque
and std::vector
(or stack).
This can be done easily enough by having a couple of template functions specialized for these containers. However, I am wondering: is there a canonical way to accomplish this in STL? Looks like I could use back_insert_iterator
for "enqueue", but I didn't find a front_remove_iterator
for "dequeue". Did I miss anything?