KiCad PCB EDA Suite
alg Namespace Reference

Functions

template<typename _InputIterator , typename _Function >
void adjacent_pairs (_InputIterator __first, _InputIterator __last, _Function __f)
 Apply a function to every sequential pair of elements of a sequence. More...
 
template<typename _InputIterator , typename _Function >
void for_all_pairs (_InputIterator __first, _InputIterator __last, _Function __f)
 Apply a function to every possible pair of elements of a sequence. More...
 

Function Documentation

◆ adjacent_pairs()

template<typename _InputIterator , typename _Function >
void alg::adjacent_pairs ( _InputIterator  __first,
_InputIterator  __last,
_Function  __f 
)

Apply a function to every sequential pair of elements of a sequence.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__fA unary function object.

Applies the function object __f to each sequential pair of elements in the range [first,last). __f must not modify the order of the sequence. If __f has a return value it is ignored.

Definition at line 41 of file kicad_algo.h.

42 {
43  if( __first != __last )
44  {
45  _InputIterator __follow = __first;
46  ++__first;
47  for( ; __first != __last; ++__first, ++__follow )
48  __f( *__follow, *__first );
49  }
50 }

◆ for_all_pairs()

template<typename _InputIterator , typename _Function >
void alg::for_all_pairs ( _InputIterator  __first,
_InputIterator  __last,
_Function  __f 
)

Apply a function to every possible pair of elements of a sequence.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__fA unary function object.

Applies the function object __f to every possible pair of elements in the range [first,last). __f must not modify the order of the sequence. If __f has a return value it is ignored.

Definition at line 63 of file kicad_algo.h.

64 {
65  if( __first != __last )
66  {
67  _InputIterator __follow = __first;
68  ++__first;
69  for( ; __first != __last; ++__first, ++__follow )
70  for( _InputIterator __it = __first; __it != __last; ++__it )
71  __f( *__follow, *__it );
72  }
73 }

Referenced by SCH_EDIT_FRAME::DeleteJunction(), and SCH_EDIT_FRAME::SchematicCleanUp().