mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-06 09:16:33 +02:00
- tabs removed
- find_tail/head_impl functions rearranged to avoid the dependency problem [SVN r32676]
This commit is contained in:
@ -75,25 +75,25 @@ namespace boost {
|
|||||||
std::locale m_Loc;
|
std::locale m_Loc;
|
||||||
};
|
};
|
||||||
|
|
||||||
// is_less functor -----------------------------------------------//
|
// is_less functor -----------------------------------------------//
|
||||||
|
|
||||||
//! is_less functor
|
//! is_less functor
|
||||||
/*!
|
/*!
|
||||||
Convenient version of standard std::less. Operation is templated, therefore it is
|
Convenient version of standard std::less. Operation is templated, therefore it is
|
||||||
not required to specify the exact types upon the construction
|
not required to specify the exact types upon the construction
|
||||||
*/
|
*/
|
||||||
struct is_less
|
struct is_less
|
||||||
{
|
{
|
||||||
//! Functor operation
|
//! Functor operation
|
||||||
/*!
|
/*!
|
||||||
Compare two operands using > operator
|
Compare two operands using > operator
|
||||||
*/
|
*/
|
||||||
template< typename T1, typename T2 >
|
template< typename T1, typename T2 >
|
||||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||||
{
|
{
|
||||||
return Arg1<Arg2;
|
return Arg1<Arg2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! case insensitive version of is_less
|
//! case insensitive version of is_less
|
||||||
@ -128,25 +128,25 @@ namespace boost {
|
|||||||
std::locale m_Loc;
|
std::locale m_Loc;
|
||||||
};
|
};
|
||||||
|
|
||||||
// is_not_greater functor -----------------------------------------------//
|
// is_not_greater functor -----------------------------------------------//
|
||||||
|
|
||||||
//! is_not_greater functor
|
//! is_not_greater functor
|
||||||
/*!
|
/*!
|
||||||
Convenient version of standard std::not_greater_to. Operation is templated, therefore it is
|
Convenient version of standard std::not_greater_to. Operation is templated, therefore it is
|
||||||
not required to specify the exact types upon the construction
|
not required to specify the exact types upon the construction
|
||||||
*/
|
*/
|
||||||
struct is_not_greater
|
struct is_not_greater
|
||||||
{
|
{
|
||||||
//! Functor operation
|
//! Functor operation
|
||||||
/*!
|
/*!
|
||||||
Compare two operands using > operator
|
Compare two operands using > operator
|
||||||
*/
|
*/
|
||||||
template< typename T1, typename T2 >
|
template< typename T1, typename T2 >
|
||||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||||
{
|
{
|
||||||
return Arg1>=Arg2;
|
return Arg1>=Arg2;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! case insensitive version of is_not_greater
|
//! case insensitive version of is_not_greater
|
||||||
@ -187,10 +187,10 @@ namespace boost {
|
|||||||
// pull names to the boost namespace
|
// pull names to the boost namespace
|
||||||
using algorithm::is_equal;
|
using algorithm::is_equal;
|
||||||
using algorithm::is_iequal;
|
using algorithm::is_iequal;
|
||||||
using algorithm::is_less;
|
using algorithm::is_less;
|
||||||
using algorithm::is_iless;
|
using algorithm::is_iless;
|
||||||
using algorithm::is_not_greater;
|
using algorithm::is_not_greater;
|
||||||
using algorithm::is_not_igreater;
|
using algorithm::is_not_igreater;
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
@ -212,9 +212,9 @@ namespace boost {
|
|||||||
typedef first_finderF<
|
typedef first_finderF<
|
||||||
search_iterator_type,
|
search_iterator_type,
|
||||||
PredicateT> first_finder_type;
|
PredicateT> first_finder_type;
|
||||||
typedef last_finderF<
|
typedef last_finderF<
|
||||||
search_iterator_type,
|
search_iterator_type,
|
||||||
PredicateT> last_finder_type;
|
PredicateT> last_finder_type;
|
||||||
|
|
||||||
// Construction
|
// Construction
|
||||||
template< typename SearchT >
|
template< typename SearchT >
|
||||||
@ -241,25 +241,25 @@ namespace boost {
|
|||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End ) const
|
ForwardIteratorT End ) const
|
||||||
{
|
{
|
||||||
if(m_Nth>=0)
|
if(m_Nth>=0)
|
||||||
{
|
{
|
||||||
return find_forward(Begin, End, m_Nth);
|
return find_forward(Begin, End, m_Nth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return find_backward(Begin, End, -m_Nth);
|
return find_backward(Begin, End, -m_Nth);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Implementation helpers
|
// Implementation helpers
|
||||||
template< typename ForwardIteratorT >
|
template< typename ForwardIteratorT >
|
||||||
iterator_range<ForwardIteratorT>
|
iterator_range<ForwardIteratorT>
|
||||||
find_forward(
|
find_forward(
|
||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End,
|
ForwardIteratorT End,
|
||||||
unsigned int N) const
|
unsigned int N) const
|
||||||
{
|
{
|
||||||
typedef ForwardIteratorT input_iterator_type;
|
typedef ForwardIteratorT input_iterator_type;
|
||||||
typedef iterator_range<ForwardIteratorT> result_type;
|
typedef iterator_range<ForwardIteratorT> result_type;
|
||||||
@ -294,7 +294,7 @@ namespace boost {
|
|||||||
find_backward(
|
find_backward(
|
||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End,
|
ForwardIteratorT End,
|
||||||
unsigned int N) const
|
unsigned int N) const
|
||||||
{
|
{
|
||||||
typedef ForwardIteratorT input_iterator_type;
|
typedef ForwardIteratorT input_iterator_type;
|
||||||
typedef iterator_range<ForwardIteratorT> result_type;
|
typedef iterator_range<ForwardIteratorT> result_type;
|
||||||
@ -333,55 +333,55 @@ namespace boost {
|
|||||||
|
|
||||||
// find head functor -----------------------------------------------//
|
// find head functor -----------------------------------------------//
|
||||||
|
|
||||||
// Find head implementation
|
template<typename ForwardIteratorT>
|
||||||
template<typename ForwardIteratorT>
|
iterator_range<ForwardIteratorT>
|
||||||
iterator_range<ForwardIteratorT>
|
find_head_impl(
|
||||||
find_head_impl(
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT Begin,
|
ForwardIteratorT End,
|
||||||
ForwardIteratorT End,
|
unsigned int N,
|
||||||
unsigned int N )
|
std::forward_iterator_tag )
|
||||||
{
|
{
|
||||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
typedef ForwardIteratorT input_iterator_type;
|
||||||
iterator_traits<ForwardIteratorT>::iterator_category category;
|
typedef iterator_range<ForwardIteratorT> result_type;
|
||||||
|
|
||||||
return find_head_impl( Begin, End, N, category() );
|
input_iterator_type It=Begin;
|
||||||
}
|
for(
|
||||||
|
unsigned int Index=0;
|
||||||
|
Index<N && It!=End; ++Index,++It ) {};
|
||||||
|
|
||||||
template<typename ForwardIteratorT>
|
return result_type( Begin, It );
|
||||||
iterator_range<ForwardIteratorT>
|
}
|
||||||
find_head_impl(
|
|
||||||
ForwardIteratorT Begin,
|
|
||||||
ForwardIteratorT End,
|
|
||||||
unsigned int N,
|
|
||||||
std::forward_iterator_tag )
|
|
||||||
{
|
|
||||||
typedef ForwardIteratorT input_iterator_type;
|
|
||||||
typedef iterator_range<ForwardIteratorT> result_type;
|
|
||||||
|
|
||||||
input_iterator_type It=Begin;
|
template< typename ForwardIteratorT >
|
||||||
for(
|
iterator_range<ForwardIteratorT>
|
||||||
unsigned int Index=0;
|
find_head_impl(
|
||||||
Index<N && It!=End; ++Index,++It ) {};
|
ForwardIteratorT Begin,
|
||||||
|
ForwardIteratorT End,
|
||||||
|
unsigned int N,
|
||||||
|
std::random_access_iterator_tag )
|
||||||
|
{
|
||||||
|
typedef ForwardIteratorT input_iterator_type;
|
||||||
|
typedef iterator_range<ForwardIteratorT> result_type;
|
||||||
|
|
||||||
return result_type( Begin, It );
|
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
|
||||||
}
|
return result_type( Begin, End );
|
||||||
|
|
||||||
template< typename ForwardIteratorT >
|
return result_type(Begin,Begin+N);
|
||||||
iterator_range<ForwardIteratorT>
|
}
|
||||||
find_head_impl(
|
|
||||||
ForwardIteratorT Begin,
|
|
||||||
ForwardIteratorT End,
|
|
||||||
unsigned int N,
|
|
||||||
std::random_access_iterator_tag )
|
|
||||||
{
|
|
||||||
typedef ForwardIteratorT input_iterator_type;
|
|
||||||
typedef iterator_range<ForwardIteratorT> result_type;
|
|
||||||
|
|
||||||
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
|
// Find head implementation
|
||||||
return result_type( Begin, End );
|
template<typename ForwardIteratorT>
|
||||||
|
iterator_range<ForwardIteratorT>
|
||||||
|
find_head_impl(
|
||||||
|
ForwardIteratorT Begin,
|
||||||
|
ForwardIteratorT End,
|
||||||
|
unsigned int N )
|
||||||
|
{
|
||||||
|
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||||
|
iterator_traits<ForwardIteratorT>::iterator_category category;
|
||||||
|
|
||||||
return result_type(Begin,Begin+N);
|
return find_head_impl( Begin, End, N, category() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// find a head in the sequence ( functor )
|
// find a head in the sequence ( functor )
|
||||||
@ -402,17 +402,17 @@ namespace boost {
|
|||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End ) const
|
ForwardIteratorT End ) const
|
||||||
{
|
{
|
||||||
if(m_N>=0)
|
if(m_N>=0)
|
||||||
{
|
{
|
||||||
return find_head_impl( Begin, End, m_N );
|
return find_head_impl( Begin, End, m_N );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iterator_range<ForwardIteratorT> Res=
|
iterator_range<ForwardIteratorT> Res=
|
||||||
find_tail_impl( Begin, End, -m_N );
|
find_tail_impl( Begin, End, -m_N );
|
||||||
|
|
||||||
return make_iterator_range(Begin, Res.begin());
|
return make_iterator_range(Begin, Res.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -421,26 +421,13 @@ namespace boost {
|
|||||||
|
|
||||||
// find tail functor -----------------------------------------------//
|
// find tail functor -----------------------------------------------//
|
||||||
|
|
||||||
// Operation
|
|
||||||
template< typename ForwardIteratorT >
|
|
||||||
iterator_range<ForwardIteratorT>
|
|
||||||
find_tail_impl(
|
|
||||||
ForwardIteratorT Begin,
|
|
||||||
ForwardIteratorT End,
|
|
||||||
unsigned int N )
|
|
||||||
{
|
|
||||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
|
||||||
iterator_traits<ForwardIteratorT>::iterator_category category;
|
|
||||||
|
|
||||||
return find_tail_impl( Begin, End, N, category() );
|
|
||||||
}
|
|
||||||
|
|
||||||
template< typename ForwardIteratorT >
|
template< typename ForwardIteratorT >
|
||||||
iterator_range<ForwardIteratorT>
|
iterator_range<ForwardIteratorT>
|
||||||
find_tail_impl(
|
find_tail_impl(
|
||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End,
|
ForwardIteratorT End,
|
||||||
unsigned int N,
|
unsigned int N,
|
||||||
std::forward_iterator_tag )
|
std::forward_iterator_tag )
|
||||||
{
|
{
|
||||||
typedef ForwardIteratorT input_iterator_type;
|
typedef ForwardIteratorT input_iterator_type;
|
||||||
@ -464,7 +451,7 @@ namespace boost {
|
|||||||
find_tail_impl(
|
find_tail_impl(
|
||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End,
|
ForwardIteratorT End,
|
||||||
unsigned int N,
|
unsigned int N,
|
||||||
std::bidirectional_iterator_tag )
|
std::bidirectional_iterator_tag )
|
||||||
{
|
{
|
||||||
typedef ForwardIteratorT input_iterator_type;
|
typedef ForwardIteratorT input_iterator_type;
|
||||||
@ -483,7 +470,7 @@ namespace boost {
|
|||||||
find_tail_impl(
|
find_tail_impl(
|
||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End,
|
ForwardIteratorT End,
|
||||||
unsigned int N,
|
unsigned int N,
|
||||||
std::random_access_iterator_tag )
|
std::random_access_iterator_tag )
|
||||||
{
|
{
|
||||||
typedef ForwardIteratorT input_iterator_type;
|
typedef ForwardIteratorT input_iterator_type;
|
||||||
@ -495,6 +482,21 @@ namespace boost {
|
|||||||
return result_type( End-N, End );
|
return result_type( End-N, End );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Operation
|
||||||
|
template< typename ForwardIteratorT >
|
||||||
|
iterator_range<ForwardIteratorT>
|
||||||
|
find_tail_impl(
|
||||||
|
ForwardIteratorT Begin,
|
||||||
|
ForwardIteratorT End,
|
||||||
|
unsigned int N )
|
||||||
|
{
|
||||||
|
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||||
|
iterator_traits<ForwardIteratorT>::iterator_category category;
|
||||||
|
|
||||||
|
return find_tail_impl( Begin, End, N, category() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// find a tail in the sequence ( functor )
|
// find a tail in the sequence ( functor )
|
||||||
/*
|
/*
|
||||||
This functor find a tail of the specified range. For
|
This functor find a tail of the specified range. For
|
||||||
@ -513,17 +515,17 @@ namespace boost {
|
|||||||
ForwardIteratorT Begin,
|
ForwardIteratorT Begin,
|
||||||
ForwardIteratorT End ) const
|
ForwardIteratorT End ) const
|
||||||
{
|
{
|
||||||
if(m_N>=0)
|
if(m_N>=0)
|
||||||
{
|
{
|
||||||
return find_tail_impl( Begin, End, m_N );
|
return find_tail_impl( Begin, End, m_N );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iterator_range<ForwardIteratorT> Res=
|
iterator_range<ForwardIteratorT> Res=
|
||||||
find_head_impl( Begin, End, -m_N );
|
find_head_impl( Begin, End, -m_N );
|
||||||
|
|
||||||
return make_iterator_range(Res.end(), End);
|
return make_iterator_range(Res.end(), End);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -333,84 +333,84 @@ namespace boost {
|
|||||||
|
|
||||||
// lexicographical_compare predicate -----------------------------//
|
// lexicographical_compare predicate -----------------------------//
|
||||||
|
|
||||||
//! Lexicographical compare predicate
|
//! Lexicographical compare predicate
|
||||||
/*!
|
/*!
|
||||||
This predicate is an overload of std::lexicographical_compare
|
This predicate is an overload of std::lexicographical_compare
|
||||||
for range arguments
|
for range arguments
|
||||||
|
|
||||||
It check whether the first argument is lexicographically less
|
It check whether the first argument is lexicographically less
|
||||||
then the second one.
|
then the second one.
|
||||||
|
|
||||||
If the optional predicate is specified, it is used for character-wise
|
If the optional predicate is specified, it is used for character-wise
|
||||||
comparison
|
comparison
|
||||||
|
|
||||||
\param Arg1 First argument
|
\param Arg1 First argument
|
||||||
\param Arg2 Second argument
|
\param Arg2 Second argument
|
||||||
\param Pred Comparison predicate
|
\param Pred Comparison predicate
|
||||||
\return The result of the test
|
\return The result of the test
|
||||||
|
|
||||||
\note This function provides the strong exception-safety guarantee
|
\note This function provides the strong exception-safety guarantee
|
||||||
*/
|
*/
|
||||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||||
inline bool lexicographical_compare(
|
inline bool lexicographical_compare(
|
||||||
const Range1T& Arg1,
|
const Range1T& Arg1,
|
||||||
const Range2T& Arg2,
|
const Range2T& Arg2,
|
||||||
PredicateT Pred)
|
PredicateT Pred)
|
||||||
{
|
{
|
||||||
return std::lexicographical_compare(
|
return std::lexicographical_compare(
|
||||||
begin(Arg1),
|
begin(Arg1),
|
||||||
end(Arg1),
|
end(Arg1),
|
||||||
begin(Arg2),
|
begin(Arg2),
|
||||||
end(Arg2),
|
end(Arg2),
|
||||||
Pred);
|
Pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Lexicographical compare predicate
|
//! Lexicographical compare predicate
|
||||||
/*!
|
/*!
|
||||||
\overload
|
\overload
|
||||||
*/
|
*/
|
||||||
template<typename Range1T, typename Range2T>
|
template<typename Range1T, typename Range2T>
|
||||||
inline bool lexicographical_compare(
|
inline bool lexicographical_compare(
|
||||||
const Range1T& Arg1,
|
const Range1T& Arg1,
|
||||||
const Range2T& Arg2)
|
const Range2T& Arg2)
|
||||||
{
|
{
|
||||||
return std::lexicographical_compare(
|
return std::lexicographical_compare(
|
||||||
begin(Arg1),
|
begin(Arg1),
|
||||||
end(Arg1),
|
end(Arg1),
|
||||||
begin(Arg2),
|
begin(Arg2),
|
||||||
end(Arg2),
|
end(Arg2),
|
||||||
is_less());
|
is_less());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Lexicographical compare predicate (case-insensitive)
|
//! Lexicographical compare predicate (case-insensitive)
|
||||||
/*!
|
/*!
|
||||||
This predicate is an overload of std::lexicographical_compare
|
This predicate is an overload of std::lexicographical_compare
|
||||||
for range arguments.
|
for range arguments.
|
||||||
It check whether the first argument is lexicographically less
|
It check whether the first argument is lexicographically less
|
||||||
then the second one.
|
then the second one.
|
||||||
Elements are compared case insensitively
|
Elements are compared case insensitively
|
||||||
|
|
||||||
|
|
||||||
\param Arg1 First argument
|
\param Arg1 First argument
|
||||||
\param Arg2 Second argument
|
\param Arg2 Second argument
|
||||||
\param Pred Comparison predicate
|
\param Pred Comparison predicate
|
||||||
\return The result of the test
|
\return The result of the test
|
||||||
|
|
||||||
\note This function provides the strong exception-safety guarantee
|
\note This function provides the strong exception-safety guarantee
|
||||||
*/
|
*/
|
||||||
template<typename Range1T, typename Range2T>
|
template<typename Range1T, typename Range2T>
|
||||||
inline bool ilexicographical_compare(
|
inline bool ilexicographical_compare(
|
||||||
const Range1T& Arg1,
|
const Range1T& Arg1,
|
||||||
const Range2T& Arg2)
|
const Range2T& Arg2)
|
||||||
{
|
{
|
||||||
return std::lexicographical_compare(
|
return std::lexicographical_compare(
|
||||||
begin(Arg1),
|
begin(Arg1),
|
||||||
end(Arg1),
|
end(Arg1),
|
||||||
begin(Arg2),
|
begin(Arg2),
|
||||||
end(Arg2),
|
end(Arg2),
|
||||||
is_iless());
|
is_iless());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// all predicate -----------------------------------------------//
|
// all predicate -----------------------------------------------//
|
||||||
|
|
||||||
@ -455,8 +455,8 @@ namespace boost {
|
|||||||
using algorithm::equals;
|
using algorithm::equals;
|
||||||
using algorithm::iequals;
|
using algorithm::iequals;
|
||||||
using algorithm::all;
|
using algorithm::all;
|
||||||
using algorithm::lexicographical_compare;
|
using algorithm::lexicographical_compare;
|
||||||
using algorithm::ilexicographical_compare;
|
using algorithm::ilexicographical_compare;
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user