
%\smallskip
%\noindent \textbf{Vector and Map Utilities}
\section{Vector and Map Utilities}
%012345678901234567890123456789012345678901234

\lstset{language=C++}
\small
\begin{lstlisting}
template<class K, class V>
  pair<V,K>
invert(pair<K,V>& p) {
    return make_pair(p.second, p.first);
}

        // map to inverted vector
template<class K, class V>
  vector<pair<V,K> >
invert(map<K,V>& m) {
    vector< pair<V,K> > v;
    FOREACH(i, m) v.push_back(invert(*i));
    return v;
}
\end{lstlisting}
\normalsize

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "ref-doc"
%%% End:
