52 #ifndef __PCL_Search_h
53 #define __PCL_Search_h
90 template <
class FI,
class T>
inline
109 template <
class FI,
class T,
class BP>
inline
110 FI
LinearSearch( FI i, FI j,
const T& v, BP p ) noexcept( noexcept( p ) )
128 template <
class BI,
class T>
inline
131 for( BI k = j; i != k; )
147 template <
class BI,
class T,
class BP>
inline
150 for( BI k = j; i != k; )
169 template <
class FI,
class T>
inline
187 return (i != j && !(v < *i)) ? i : j;
203 template <
class FI,
class T,
class BP>
inline
204 FI
BinarySearch( FI i, FI j,
const T& v, BP p ) noexcept( noexcept( p ) )
221 return (i != j && !p( v, *i )) ? i : j;
237 template <
class FI,
class T>
inline
242 for( FI l = k; ++l != j && *l == v; )
260 template <
class FI,
class T,
class BP>
inline
265 for( FI l = k; ++l != j && !p( *l, v ) && !p( v, *l ); )
284 template <
class FI,
class T,
class BP1,
class BP2>
inline
285 FI
BinarySearch( FI i, FI j,
const T& v, BP1 p1, BP2 p2 ) noexcept( noexcept( p1 ) && noexcept( p2 ) )
302 return (i != j && !p2( v, *i )) ? i : j;
325 template <
class FI,
class T>
inline
366 template <
class FI,
class T,
class BP>
inline
396 template <
class FI1,
class FI2>
inline
397 FI1
Search( FI1 i1, FI1 j1, FI2 i2, FI2 j2 ) noexcept
401 if ( n1 > 0 && n2 > 0 )
402 for ( ; n2 <= n1; ++i1, --n1 )
406 for ( ; *k1 == *k2; ++k1 )
422 template <
class FI1,
class FI2,
class BP>
inline
423 FI1
Search( FI1 i1, FI1 j1, FI2 i2, FI2 j2, BP p ) noexcept( noexcept( p ) )
427 if ( n1 > 0 && n2 > 0 )
428 for ( ; n2 <= n1; ++i1, --n1 )
432 for ( ; p( *k1, *k2 ); ++k1 )
448 template <
class BI1,
class FI2>
inline
453 if ( n1 > 0 && n2 > 0 && n2 <= n1 )
455 i1.Advance( n1 - n2 );
460 for ( ; *k1 == *k2; ++k1 )
480 template <
class BI1,
class FI2,
class BP>
inline
481 BI1
SearchLast( BI1 i1, BI1 j1, FI2 i2, FI2 j2, BP p ) noexcept( noexcept( p ) )
485 if ( n1 > 0 && n2 > 0 && n2 <= n1 )
487 i1.Advance( n1 - n2 );
492 for ( ; p( *k1, *k2 ); ++k1 )
FI BinarySearch(FI i, FI j, const T &v) noexcept
FI LinearSearch(FI i, FI j, const T &v) noexcept
BI1 SearchLast(BI1 i1, BI1 j1, FI2 i2, FI2 j2) noexcept
FI BinarySearchLast(FI i, FI j, const T &v) noexcept
BI LinearSearchLast(BI i, BI j, const T &v) noexcept
FI1 Search(FI1 i1, FI1 j1, FI2 i2, FI2 j2) noexcept
FI InsertionPoint(FI i, FI j, const T &v) noexcept
void Advance(FI &i, distance_type d)
distance_type Distance(FI i, FI j)