1 /*
2 * Inkscape::Algorithms::find_if_before - finds the position before
3 * the first value that satisifes
4 * the predicate
5 *
6 * Authors:
7 * MenTaLguY <mental@rydia.net>
8 *
9 * Copyright (C) 2005 MenTaLguY
10 *
11 * Released under GNU GPL, read the file 'COPYING' for more information
12 */
14 #ifndef SEEN_INKSCAPE_ALGORITHMS_FIND_IF_BEFORE_H
15 #define SEEN_INKSCAPE_ALGORITHMS_FIND_IF_BEFORE_H
17 #include <algorithm>
19 namespace Inkscape {
21 namespace Algorithms {
23 template <typename ForwardIterator, typename UnaryPredicate>
24 inline ForwardIterator find_if_before(ForwardIterator start,
25 ForwardIterator end,
26 UnaryPredicate pred)
27 {
28 ForwardIterator before=end;
29 while ( start != end && !pred(*start) ) {
30 before = start;
31 ++start;
32 }
33 return ( start != end ) ? before : end;
34 }
36 }
38 }
40 #endif
42 /*
43 Local Variables:
44 mode:c++
45 c-file-style:"stroustrup"
46 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
47 indent-tabs-mode:nil
48 fill-column:99
49 End:
50 */
51 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :