PCL
Utility Algorithms

## Macros

#define ItemsInArray(a)   (sizeof( a )/sizeof( *a ))

## Functions

template<class FI , class F >
void pcl::Apply (FI i, FI j, F f)

template<class FI , class F , typename T1 >
void pcl::Apply (FI i, FI j, F f, T1 x)

template<class FI , class F , class UP >
void pcl::ApplyIf (FI i, FI j, F f, UP p)

template<class FI , class F , class UP , typename T1 >
void pcl::ApplyIf (FI i, FI j, F f, UP p, T1 x)

template<class FI1 , class FI2 >
int pcl::Compare (FI1 i1, FI1 j1, FI2 i2, FI2 j2)

template<class FI1 , class FI2 , class BP >
int pcl::Compare (FI1 i1, FI1 j1, FI2 i2, FI2 j2, BP p)

template<class FI , typename T >
size_type pcl::Count (FI i, FI j, const T &v)

template<class FI , typename T , class BP >
size_type pcl::Count (FI i, FI j, const T &v, BP p)

template<class FI , class UP >
size_type pcl::CountIf (FI i, FI j, UP p)

template<class FI1 , class FI2 >
bool pcl::Equal (FI1 i1, FI2 i2, FI2 j2)

template<class FI1 , class FI2 , class BP >
bool pcl::Equal (FI1 i1, FI2 i2, FI2 j2, BP p)

template<class FI >
void pcl::FindExtremeItems (FI &kmin, FI &kmax, FI i, FI j)

template<class FI , class BP >
void pcl::FindExtremeItems (FI &kmin, FI &kmax, FI i, FI j, BP p)

template<class FI1 , class FI2 >
Association< FI1, FI2 > pcl::FindNotEqual (FI1 i1, FI2 i2, FI2 j2)

template<class FI1 , class FI2 , class BP >
Association< FI1, FI2 > pcl::FindNotEqual (FI1 i1, FI2 i2, FI2 j2, BP p)

template<class FI , class UP >
FI pcl::FirstThat (FI i, FI j, UP p)

template<class FI , class UP , typename T1 >
FI pcl::FirstThat (FI i, FI j, UP p, T1 x)

template<class BI , class UP >
BI pcl::LastThat (BI i, BI j, UP p)

template<class BI , class UP , typename T1 >
BI pcl::LastThat (BI i, BI j, UP p, T1 x)

template<typename T >
constexpr const T & pcl::Max (const T &a, const T &b)

template<typename T , class BP >
const T & pcl::Max (const T &a, const T &b, BP p)

template<class FI >
FI pcl::MaxItem (FI i, FI j)

template<class FI , class BP >
FI pcl::MaxItem (FI i, FI j, BP p)

template<typename T >
constexpr const T & pcl::Median (const T &a, const T &b, const T &c)

template<typename T , class BP >
const T & pcl::Median (const T &a, const T &b, const T &c, BP p)

template<typename T >
constexpr const T & pcl::Min (const T &a, const T &b)

template<typename T , class BP >
const T & pcl::Min (const T &a, const T &b, BP p)

template<class FI >
FI pcl::MinItem (FI i, FI j)

template<class FI , class BP >
FI pcl::MinItem (FI i, FI j, BP p)

template<typename T >
constexpr const T & pcl::Range (const T &x, const T &a, const T &b)

template<typename T , class BP >
const T & pcl::Range (const T &x, const T &a, const T &b, BP p)

template<typename T >
void pcl::Swap (T &a, T &b) noexcept(std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_copy_assignable< T >::value &&std::is_nothrow_move_assignable< T >::value)

## Detailed Description

Template formal parameters:

FI Forward iterator
BI Bidirectional iterator
RI Random access iterator
UP Unary predicate
BP Binary predicate
T Item type
F Function

## ◆ ItemsInArray

 #define ItemsInArray ( a ) (sizeof( a )/sizeof( *a ))

Returns the number of elements in the specified C array a.

Definition at line 223 of file Utility.h.

## ◆ Apply() [1/2]

template<class FI , class F >
 void pcl::Apply ( FI i, FI j, F f )
inline

Applies a unary function f to the range [i,j). For each iterator t in the range [i,j) this function performs the function call f(*t).

Definition at line 249 of file Utility.h.

## ◆ Apply() [2/2]

template<class FI , class F , typename T1 >
 void pcl::Apply ( FI i, FI j, F f, T1 x )
inline

Applies a binary function f to the range [i,j) with the specified right-hand constant argument x. For each iterator t in the range [i,j) this function performs the function call f(*t,x).

Definition at line 265 of file Utility.h.

## ◆ ApplyIf() [1/2]

template<class FI , class F , class UP >
 void pcl::ApplyIf ( FI i, FI j, F f, UP p )
inline

Applies a unary function f to those elements in the range [i,j) that satisfy a condition given by a unary predicate p. For each iterator t in the range [i,j) this function performs the function call f(*t) if and only if p(*t) is true.

Definition at line 282 of file Utility.h.

## ◆ ApplyIf() [2/2]

template<class FI , class F , class UP , typename T1 >
 void pcl::ApplyIf ( FI i, FI j, F f, UP p, T1 x )
inline

Applies a unary function f to those elements in the range [i,j) that satisfy a condition given by a unary predicate p, with right-hand constant argument x. For each iterator t in the range [i,j) this function performs the function call f(*t,x) if and only if p(*t) is true.

Definition at line 300 of file Utility.h.

## ◆ Compare() [1/2]

template<class FI1 , class FI2 >
 int pcl::Compare ( FI1 i1, FI1 j1, FI2 i2, FI2 j2 )
inline

Performs a comparison of the objects in the ranges [i1,j1) and [i2,j2). Returns the result of the comparison encoded as an integer:

Returns 0 if:

• (1) Distance(i1,j1) == Distance(i2,j2).
• (2) For each pair {u,v} of iterators such that u in [i1,j1) and v in [i2,j2) and Distance(i1,u) == Distance(i2,v), *u == *v.

Returns -1 if:

• (3) A pair {u,v} of iterators exists such that u in [i1,j1) and v in [i2,j2) and Distance(i1,u) == Distance(i2,v) and *u < *v.
• (4) Condition (2) is true and Distance(i1,j1) < Distance(i2,j2).

Returns +1 if:

• (5) A pair {u,v} of iterators exists such that u in [i1,j1) and v in [i2,j2) and Distance(i1,u) == Distance(i2,v) and *v < *u.
• (6) Condition (2) is true and Distance(i1,j1) > Distance(i2,j2).

Definition at line 639 of file Utility.h.

## ◆ Compare() [2/2]

template<class FI1 , class FI2 , class BP >
 int pcl::Compare ( FI1 i1, FI1 j1, FI2 i2, FI2 j2, BP p )
inline

Performs a comparison of the objects in the ranges [i1,j1) and [i2,j2) as specified by a binary predicate p. Returns the result of the comparison encoded as an integer:

Returns 0 if:

• (1) Distance(i1,j1) == Distance(i2,j2).
• (2) For each pair {u,v} of iterators such that u in [i1,j1) and v in [i2,j2) and Distance(i1,u) == Distance(i2,v), both p(*u,*v) and p(*v,*u) are false.

Returns -1 if:

• (3) A pair {u,v} of iterators exists such that u in [i1,j1) and v in [i2,j2) and Distance(i1,u) == Distance(i2,v) and p(*u,*v) is true.
• (4) Condition (2) is true and Distance(i1,j1) < Distance(i2,j2).

Returns +1 if:

• (5) A pair {u,v} of iterators exists such that u in [i1,j1) and v in [i2,j2) and Distance(i1,u) == Distance(i2,v) and p(*v,*u) is true.
• (6) Condition (2) is true and Distance(i1,j1) > Distance(i2,j2).

Definition at line 683 of file Utility.h.

## ◆ Count() [1/2]

template<class FI , typename T >
 size_type pcl::Count ( FI i, FI j, const T & v )
inline

Returns the total number of objects in the range [i,j) that are equal to the specified constant object v.

Definition at line 384 of file Utility.h.

## ◆ Count() [2/2]

template<class FI , typename T , class BP >
 size_type pcl::Count ( FI i, FI j, const T & v, BP p )
inline

Returns the total number of objects in the range [i,j) that are equal to a constant object v, as specified by the binary predicate p. For each iterator t in the range [i,j), counts the number of objects for which p(*t,v) is true.

Definition at line 404 of file Utility.h.

## ◆ CountIf()

template<class FI , class UP >
 size_type pcl::CountIf ( FI i, FI j, UP p )
inline

Returns the total number of objects in the range [i,j) that satisfy a condition given by a unary predicate p. For each iterator t in the range [i,j), counts the number of objects for which p(*t) is true.

Definition at line 423 of file Utility.h.

## ◆ Equal() [1/2]

template<class FI1 , class FI2 >
 bool pcl::Equal ( FI1 i1, FI2 i2, FI2 j2 )
inline

Returns true iff the objects in the range [i1,j1) are equal to the corresponding objects in the range [i2,j2), with j1 = Advance(i1,Distance(i2,j2)).

Definition at line 592 of file Utility.h.

References pcl::FindNotEqual().

## ◆ Equal() [2/2]

template<class FI1 , class FI2 , class BP >
 bool pcl::Equal ( FI1 i1, FI2 i2, FI2 j2, BP p )
inline

Returns true iff the objects in the range [i1,j1) satisfy the condition specified by the binary predicate p for the corresponding objects in the range [i2,j2), with j1 = Advance(i1,Distance(i2,j2)).

Definition at line 607 of file Utility.h.

References pcl::FindNotEqual().

## ◆ FindExtremeItems() [1/2]

template<class FI >
 void pcl::FindExtremeItems ( FI & kmin, FI & kmax, FI i, FI j )
inline

Finds two iterators n and m in the range [i,j) such that *n <= *u for any u != n in [i,j) and *m >= *v for any v != m in [i,j).

Definition at line 517 of file Utility.h.

## ◆ FindExtremeItems() [2/2]

template<class FI , class BP >
 void pcl::FindExtremeItems ( FI & kmin, FI & kmax, FI i, FI j, BP p )
inline

Finds two iterators n and m in the range [i,j) such that p(*u,*n) is false for any u != n in [i,j) and p(*m,*v) is false for any v != m in [i,j).

Definition at line 539 of file Utility.h.

## ◆ FindNotEqual() [1/2]

template<class FI1 , class FI2 >
 Association pcl::FindNotEqual ( FI1 i1, FI2 i2, FI2 j2 )
inline

Returns a tuple {i,j} such that *i != *j, where i >= i1 and j is in the range [i2,j2), or a tuple {i>=i1,j2} if no such j exists.

Definition at line 561 of file Utility.h.

References pcl::Associate().

Referenced by pcl::Equal().

## ◆ FindNotEqual() [2/2]

template<class FI1 , class FI2 , class BP >
 Association pcl::FindNotEqual ( FI1 i1, FI2 i2, FI2 j2, BP p )
inline

Returns a tuple {i,j} such that p(*i,*j) is false, where i >= i1 and j is in the range [i2,j2), or a tuple {i>=i1,j2} if no such j exists.

Definition at line 576 of file Utility.h.

References pcl::Associate().

## ◆ FirstThat() [1/2]

template<class FI , class UP >
 FI pcl::FirstThat ( FI i, FI j, UP p )
inline

Returns the first iterator t in the range [i,j) such that the specified unary predicate p(*t) is true, or j if no such iterator exists.

Definition at line 316 of file Utility.h.

## ◆ FirstThat() [2/2]

template<class FI , class UP , typename T1 >
 FI pcl::FirstThat ( FI i, FI j, UP p, T1 x )
inline

Returns the first iterator t in the range [i,j) such that the specified unary predicate p(*t,x) is true, or j if no such iterator exists.

Definition at line 333 of file Utility.h.

## ◆ LastThat() [1/2]

template<class BI , class UP >
 BI pcl::LastThat ( BI i, BI j, UP p )
inline

Returns the last iterator t in the range [i,j) such that the specified unary predicate p(*t) is true, or j if no such iterator exists.

Definition at line 350 of file Utility.h.

## ◆ LastThat() [2/2]

template<class BI , class UP , typename T1 >
 BI pcl::LastThat ( BI i, BI j, UP p, T1 x )
inline

Returns the last iterator t in the range [i,j) such that the specified unary predicate p(*t,x) is true, or j if no such iterator exists.

Definition at line 367 of file Utility.h.

## ◆ Max() [1/2]

template<typename T >
 constexpr const T& pcl::Max ( const T & a, const T & b )
inline

## ◆ Max() [2/2]

template<typename T , class BP >
 const T& pcl::Max ( const T & a, const T & b, BP p )
inline

Returns a reference to the largest of two objects a and b, as specified by the binary predicate p. Returns b if p(a,b) is true; returns a otherwise.

Definition at line 134 of file Utility.h.

## ◆ MaxItem() [1/2]

template<class FI >
 FI pcl::MaxItem ( FI i, FI j )
inline

Returns an iterator m in the range [i,j) such that *m >= *t for any t != m in [i,j). Returns j if and only if i == j.

Definition at line 479 of file Utility.h.

## ◆ MaxItem() [2/2]

template<class FI , class BP >
 FI pcl::MaxItem ( FI i, FI j, BP p )
inline

Returns an iterator m in the range [i,j) such that p(*m,*t) is false for any t != m in [i,j). Returns j if and only if i == j.

Definition at line 498 of file Utility.h.

## ◆ Median() [1/2]

template<typename T >
 constexpr const T& pcl::Median ( const T & a, const T & b, const T & c )
inline

Returns a reference to the median of three objects a, b and c:

• a if (c <= a < b) || (b <= a < c)
• b if (a < b < c) || (c <= b <= a)
• c if (a < c < b) || (b < c <= a)

Definition at line 151 of file Utility.h.

## ◆ Median() [2/2]

template<typename T , class BP >
 const T& pcl::Median ( const T & a, const T & b, const T & c, BP p )
inline

Returns a reference to the median of three objects a, b and c, as specified by the binary predicate p:

• a if p(a,b) && !p(b,c) && !p(a,c) || !p(a,b) && p(a,c)
• b if p(a,b) && p(b,c) || !p(a,b) && !p(a,c) && !p(b,c)
• c if p(a,b) && !p(b,c) && p(a,c) || !p(a,b) && !p(a,c) && p(b,c)

Definition at line 170 of file Utility.h.

## ◆ Min() [1/2]

template<typename T >
 constexpr const T& pcl::Min ( const T & a, const T & b )
inline

## ◆ Min() [2/2]

template<typename T , class BP >
 const T& pcl::Min ( const T & a, const T & b, BP p )
inline

Returns a reference to the smallest of two objects a and b, as specified by the binary predicate p. Returns b if p(b,a) is true; returns a otherwise.

Definition at line 105 of file Utility.h.

## ◆ MinItem() [1/2]

template<class FI >
 FI pcl::MinItem ( FI i, FI j )
inline

Returns an iterator m in the range [i,j) such that *m <= *t for any t != m in [i,j). Returns j if and only if i == j.

Definition at line 441 of file Utility.h.

## ◆ MinItem() [2/2]

template<class FI , class BP >
 FI pcl::MinItem ( FI i, FI j, BP p )
inline

Returns an iterator m in the range [i,j) such that p(*t,*m) is false for any t != m in [i,j). Returns j if and only if i == j.

Definition at line 460 of file Utility.h.

## ◆ Range() [1/2]

template<typename T >
 constexpr const T& pcl::Range ( const T & x, const T & a, const T & b )
inline

## ◆ Range() [2/2]

template<typename T , class BP >
 const T& pcl::Range ( const T & x, const T & a, const T & b, BP p )
inline

Returns a reference to the specified object x, if and only if it belongs to the range [a,b], as specified by the binary predicate p. Returns a reference to the nearest range bounding object otherwise. Returns:

• x if !p(x,a) && !p(b,x)
• a if p(x,a)
• b if p(b,x)

Definition at line 210 of file Utility.h.

## ◆ Swap()

template<typename T >
 void pcl::Swap ( T & a, T & b )
inlinenoexcept

Exchanges two objects a and b.

Definition at line 233 of file Utility.h.