Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / algorithm / string / detail / predicate.hpp @ 2486

History | View | Annotate | Download (2.4 kB)

1 2486 sjacqu01
//  Boost string_algo library predicate.hpp header file  ---------------------------//
2 2486 sjacqu01
3 2486 sjacqu01
//  Copyright Pavol Droba 2002-2003.
4 2486 sjacqu01
//
5 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0.
6 2486 sjacqu01
//    (See accompanying file LICENSE_1_0.txt or copy at
7 2486 sjacqu01
//          http://www.boost.org/LICENSE_1_0.txt)
8 2486 sjacqu01
9 2486 sjacqu01
//  See http://www.boost.org/ for updates, documentation, and revision history.
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_STRING_PREDICATE_DETAIL_HPP
12 2486 sjacqu01
#define BOOST_STRING_PREDICATE_DETAIL_HPP
13 2486 sjacqu01
14 2486 sjacqu01
#include <iterator>
15 2486 sjacqu01
#include <boost/algorithm/string/find.hpp>
16 2486 sjacqu01
17 2486 sjacqu01
namespace boost {
18 2486 sjacqu01
    namespace algorithm {
19 2486 sjacqu01
        namespace detail {
20 2486 sjacqu01
21 2486 sjacqu01
//  ends_with predicate implementation ----------------------------------//
22 2486 sjacqu01
23 2486 sjacqu01
            template<
24 2486 sjacqu01
                typename ForwardIterator1T,
25 2486 sjacqu01
                typename ForwardIterator2T,
26 2486 sjacqu01
                typename PredicateT>
27 2486 sjacqu01
            inline bool ends_with_iter_select(
28 2486 sjacqu01
                ForwardIterator1T Begin,
29 2486 sjacqu01
                ForwardIterator1T End,
30 2486 sjacqu01
                ForwardIterator2T SubBegin,
31 2486 sjacqu01
                ForwardIterator2T SubEnd,
32 2486 sjacqu01
                PredicateT Comp,
33 2486 sjacqu01
                std::bidirectional_iterator_tag)
34 2486 sjacqu01
            {
35 2486 sjacqu01
                ForwardIterator1T it=End;
36 2486 sjacqu01
                ForwardIterator2T pit=SubEnd;
37 2486 sjacqu01
                for(;it!=Begin && pit!=SubBegin;)
38 2486 sjacqu01
                {
39 2486 sjacqu01
                    if( !(Comp(*(--it),*(--pit))) )
40 2486 sjacqu01
                        return false;
41 2486 sjacqu01
                }
42 2486 sjacqu01
43 2486 sjacqu01
                return pit==SubBegin;
44 2486 sjacqu01
            }
45 2486 sjacqu01
46 2486 sjacqu01
            template<
47 2486 sjacqu01
                typename ForwardIterator1T,
48 2486 sjacqu01
                typename ForwardIterator2T,
49 2486 sjacqu01
                typename PredicateT>
50 2486 sjacqu01
            inline bool ends_with_iter_select(
51 2486 sjacqu01
                ForwardIterator1T Begin,
52 2486 sjacqu01
                ForwardIterator1T End,
53 2486 sjacqu01
                ForwardIterator2T SubBegin,
54 2486 sjacqu01
                ForwardIterator2T SubEnd,
55 2486 sjacqu01
                PredicateT Comp,
56 2486 sjacqu01
                std::forward_iterator_tag)
57 2486 sjacqu01
            {
58 2486 sjacqu01
                if ( SubBegin==SubEnd )
59 2486 sjacqu01
                {
60 2486 sjacqu01
                    // empty subsequence check
61 2486 sjacqu01
                    return true;
62 2486 sjacqu01
                }
63 2486 sjacqu01
64 2486 sjacqu01
                iterator_range<ForwardIterator1T> Result
65 2486 sjacqu01
                    =last_finder(
66 2486 sjacqu01
                        ::boost::make_iterator_range(SubBegin, SubEnd),
67 2486 sjacqu01
                        Comp)(Begin, End);
68 2486 sjacqu01
69 2486 sjacqu01
                return !Result.empty() && Result.end()==End;
70 2486 sjacqu01
            }
71 2486 sjacqu01
72 2486 sjacqu01
        } // namespace detail
73 2486 sjacqu01
    } // namespace algorithm
74 2486 sjacqu01
} // namespace boost
75 2486 sjacqu01
76 2486 sjacqu01
77 2486 sjacqu01
#endif  // BOOST_STRING_PREDICATE_DETAIL_HPP