Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:24

0001 //  Boost string_algo library predicate.hpp header file  ---------------------------//
0002 
0003 //  Copyright Pavol Droba 2002-2003.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 //  See http://www.boost.org/ for updates, documentation, and revision history.
0010 
0011 #ifndef BOOST_STRING_PREDICATE_DETAIL_HPP
0012 #define BOOST_STRING_PREDICATE_DETAIL_HPP
0013 
0014 #include <iterator>
0015 #include <boost/algorithm/string/find.hpp>
0016 
0017 namespace boost {
0018     namespace algorithm {
0019         namespace detail {
0020 
0021 //  ends_with predicate implementation ----------------------------------//
0022 
0023             template< 
0024                 typename ForwardIterator1T, 
0025                 typename ForwardIterator2T,
0026                 typename PredicateT>
0027             inline bool ends_with_iter_select( 
0028                 ForwardIterator1T Begin, 
0029                 ForwardIterator1T End, 
0030                 ForwardIterator2T SubBegin,
0031                 ForwardIterator2T SubEnd,
0032                 PredicateT Comp,
0033                 std::bidirectional_iterator_tag)
0034             {
0035                 ForwardIterator1T it=End;
0036                 ForwardIterator2T pit=SubEnd;
0037                 for(;it!=Begin && pit!=SubBegin;)
0038                 {
0039                     if( !(Comp(*(--it),*(--pit))) )
0040                         return false;
0041                 }
0042 
0043                 return pit==SubBegin;
0044             }
0045 
0046             template< 
0047                 typename ForwardIterator1T, 
0048                 typename ForwardIterator2T,
0049                 typename PredicateT>
0050             inline bool ends_with_iter_select( 
0051                 ForwardIterator1T Begin, 
0052                 ForwardIterator1T End, 
0053                 ForwardIterator2T SubBegin,
0054                 ForwardIterator2T SubEnd,
0055                 PredicateT Comp,
0056                 std::forward_iterator_tag)
0057             {
0058                 if ( SubBegin==SubEnd )
0059                 {
0060                     // empty subsequence check
0061                     return true;
0062                 }
0063 
0064                 iterator_range<ForwardIterator1T> Result
0065                     =last_finder( 
0066                         ::boost::make_iterator_range(SubBegin, SubEnd),
0067                         Comp)(Begin, End);
0068 
0069                 return !Result.empty() && Result.end()==End;
0070             }
0071 
0072         } // namespace detail
0073     } // namespace algorithm
0074 } // namespace boost
0075 
0076 
0077 #endif  // BOOST_STRING_PREDICATE_DETAIL_HPP