I implement four algorithms that are completely identical, except for the data structure that they use - two use priority_queue, one uses stack, and the last uses queue. They are relatively long, so I would like to have only one function template that takes the container type as the template argument, and then each algorithm calls this template with the corresponding argument, for example:
template <class Container>
void foo(/* args */)
{
Container dataStructure;
}
void queueBased()
{
foo<queue<Item> >();
}
void stackBased()
{
foo<stack<Item> >();
}
priority_queue - stack, queue, (front( ) top( )). , , ( ).
? - , top( ), stack, , STL - -. ?