1 #ifndef __REMOVE_LAST_H__
2 #define __REMOVE_LAST_H__
4 #include <algorithm>
5 #include <vector>
6 #include <glib.h>
8 template<class T>
9 inline void remove_last(std::vector<T> &seq, T const &elem)
10 {
11 using std::vector;
13 typename vector<T>::reverse_iterator i(find(seq.rbegin(), seq.rend(), elem));
14 g_assert( i != seq.rend() );
15 typename vector<T>::iterator ii(&*i);
16 seq.erase(ii);
17 }
20 #endif /* !__REMOVE_LAST_H__ */
23 /*
24 Local Variables:
25 mode:c++
26 c-file-style:"stroustrup"
27 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
28 indent-tabs-mode:nil
29 fill-column:99
30 End:
31 */
32 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :