STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
Functions

Initialize the elements in a view (e.g., stapl::generate()). Defined in stapl/algorithms/algorithm.hpp. More...

+ Collaboration diagram for Generating Operations:

Functions

template<typename View0 , typename View1 >
void stapl::copy (View0 const &vw0, View1 const &vw1)
 Copy the elements of the input view to the output view. More...
 
template<typename View0 , typename View1 , typename Size >
void stapl::copy_n (View0 const &vw0, View1 const &vw1, Size n)
 Copy the first n elements from the input view to the output view. More...
 
template<typename View , typename Generator >
void stapl::generate (View const &view, Generator gen)
 Assign each value of the input view to the result of calling the provided functor. More...
 
template<typename View , typename Generator >
void stapl::generate_n (View const &view, size_t first_elem, size_t n, Generator gen)
 Assign the n values of the input view starting at the given element to the result of calling the provided functor. More...
 
template<typename View , typename Predicate >
void stapl::replace_if (View &vw, Predicate pred, typename View::value_type const &new_value)
 Replace the values from the input view for which the given predicate returns true with the new value. More...
 
template<typename View >
void stapl::replace (View &vw, typename View::value_type const &old_value, typename View::value_type const &new_value)
 Replace the given value in the input with the new value. More...
 
template<typename View0 , typename View1 , typename Predicate >
View1::iterator stapl::replace_copy_if (View0 const &vw0, View1 const &vw1, Predicate pred, typename View0::value_type new_value)
 Copy the values from the input view to the output, except for those elements for which the given predicate returns true, which are replaced with the given value. More...
 
template<typename View , typename Size >
void stapl::fill_n (View &vw, typename View::value_type value, Size n)
 Assigns the given value to the first n elements of the input view. More...
 
template<typename View >
void stapl::fill (View const &vw, typename View::value_type value)
 Assigns the given value to the elements of the input view. More...
 
template<typename View >
void stapl::swap_ranges (View &vw0, View &vw1)
 Swaps the elements of the two input views. More...
 
template<typename View0 , typename View1 >
View1::iterator stapl::replace_copy (View0 &vw0, View1 &vw1, typename View0::value_type old_value, typename View0::value_type new_value)
 Copy the elements from the input to the output, replacing the given old_value with the new_value. More...
 
template<typename View0 , typename Function >
Function stapl::for_each (const View0 &vw0, Function func)
 Applies the given functor to all of the elements in the input. More...
 
template<typename View0 , typename View1 , typename Function >
void stapl::transform (const View0 &vw0, const View1 &vw1, Function func)
 Applies the given function to the input, and stores the result in the output. More...
 
template<typename View0 , typename View1 , typename View2 , typename Function >
void stapl::transform (View0 &vw0, View1 &vw1, View2 &vw2, Function func)
 Applies the given function to the inputs, and stores the result in the output. More...
 
template<typename View >
void stapl::prototype::fill (View &vw, typename View::value_type value)
 Assigns the given value to the elements of the input view. More...
 
template<typename View0 , typename Function >
Function stapl::prototype::for_each (View0 const &vw0, Function func)
 Applies the given functor to all of the elements in the input. More...
 
template<typename View0 >
void stapl::iota (View0 const &view, typename View0::value_type const &value)
 Initializes the elements of the view such that the first element is assigned value, the next element value+1, etc. More...
 

Detailed Description

Initialize the elements in a view (e.g., stapl::generate()). Defined in stapl/algorithms/algorithm.hpp.

Modifies the elements in a view by assigning values that are:

Function Documentation

◆ copy()

template<typename View0 , typename View1 >
void stapl::copy ( View0 const &  vw0,
View1 const &  vw1 
)

Copy the elements of the input view to the output view.

Parameters
vw0One-dimensional view of the input.
vw1One-dimensional view of the output.

This algorithm mutates the output.

◆ copy_n()

template<typename View0 , typename View1 , typename Size >
void stapl::copy_n ( View0 const &  vw0,
View1 const &  vw1,
Size  n 
)

Copy the first n elements from the input view to the output view.

Parameters
vw0One-dimensional view of the input.
vw1One-dimensional view of the output.
nNumber of elements to copy.

This algorithm mutates the output.

◆ generate()

template<typename View , typename Generator >
void stapl::generate ( View const &  view,
Generator  gen 
)

Assign each value of the input view to the result of calling the provided functor.

Parameters
viewOne-dimensional view of the input.
genNullary functor which is called to generate elements.

This algorithm mutates the input view.

◆ generate_n()

template<typename View , typename Generator >
void stapl::generate_n ( View const &  view,
size_t  first_elem,
size_t  n,
Generator  gen 
)

Assign the n values of the input view starting at the given element to the result of calling the provided functor.

Parameters
viewOne-dimensional view of the input.
first_elemFirst element to fill with a generated value.
nNumber of elements to fill with generated values.
genNullary functor which is called to generate elements.

This algorithm mutates the input view.

◆ replace_if()

template<typename View , typename Predicate >
void stapl::replace_if ( View &  vw,
Predicate  pred,
typename View::value_type const &  new_value 
)

Replace the values from the input view for which the given predicate returns true with the new value.

Parameters
vwOne-dimensional view of the input.
predUnary functor which returns true for replaced elements.
new_valueValue used to replace elements.

This algorithm mutates the input view.

◆ replace()

template<typename View >
void stapl::replace ( View &  vw,
typename View::value_type const &  old_value,
typename View::value_type const &  new_value 
)

Replace the given value in the input with the new value.

Parameters
vwOne-dimensional view of the input.
old_valueValue replaced in the input.
new_valueValue used to replace old values.

This algorithm mutates the input view. The comparison is done with stapl::equal_to.

◆ replace_copy_if()

template<typename View0 , typename View1 , typename Predicate >
View1::iterator stapl::replace_copy_if ( View0 const &  vw0,
View1 const &  vw1,
Predicate  pred,
typename View0::value_type  new_value 
)

Copy the values from the input view to the output, except for those elements for which the given predicate returns true, which are replaced with the given value.

Parameters
vw0One-dimensional view of the input.
vw1One-dimensional view of the output.
predUnary functor which returns true for replaced elements.
new_valueValue used to replace elements for which the functor returns true.
Returns
Iterator pointing to the end of the output view.

This algorithm mutates the output view. The input and output views must be the same size.

◆ fill_n()

template<typename View , typename Size >
void stapl::fill_n ( View &  vw,
typename View::value_type  value,
Size  n 
)

Assigns the given value to the first n elements of the input view.

Parameters
vwOne-dimensional view of the input.
valueThe value to fill into the input.
nNumber of elements to fill.

This algorithm mutates the input view. The input must be at least n in size.

◆ fill() [1/2]

template<typename View >
void stapl::fill ( View const &  vw,
typename View::value_type  value 
)

Assigns the given value to the elements of the input view.

Parameters
vwOne-dimensional view of the input.
valueThe value to fill into the input.

This algorithm mutates the input view.

◆ swap_ranges()

template<typename View >
void stapl::swap_ranges ( View &  vw0,
View &  vw1 
)

Swaps the elements of the two input views.

Parameters
vw0One-dimensional view of the first input.
vw1One-dimensional view of the second input.

This algorithm mutates both input views, and requires that both views are the same size.

◆ replace_copy()

template<typename View0 , typename View1 >
View1::iterator stapl::replace_copy ( View0 &  vw0,
View1 &  vw1,
typename View0::value_type  old_value,
typename View0::value_type  new_value 
)

Copy the elements from the input to the output, replacing the given old_value with the new_value.

Parameters
vw0One-dimensional view of the input.
vw1One-dimensional view of the output.
old_valueThe old value to replace.
new_valueThe new value to substitute for occurrences of old_value.
Returns
Iterator to the end of the newly copied view.

This algorithm mutates the output view, and requires a view with iterator support. It uses stapl::equal_to for comparisons.

◆ for_each() [1/2]

template<typename View0 , typename Function >
Function stapl::for_each ( const View0 &  vw0,
Function  func 
)

Applies the given functor to all of the elements in the input.

Parameters
vw0One-dimensional view over the input.
funcUnary functor to apply to the elements.
Returns
The functor that was passed as input.

This algorithm will mutate the input view.

◆ transform() [1/2]

template<typename View0 , typename View1 , typename Function >
void stapl::transform ( const View0 &  vw0,
const View1 &  vw1,
Function  func 
)

Applies the given function to the input, and stores the result in the output.

Parameters
vw0One-dimensional view over the input.
vw1One-dimensional view over the output.
funcUnary function which is applied to all of the input elements.

This algorithm mutates the output view only.

◆ transform() [2/2]

template<typename View0 , typename View1 , typename View2 , typename Function >
void stapl::transform ( View0 &  vw0,
View1 &  vw1,
View2 &  vw2,
Function  func 
)

Applies the given function to the inputs, and stores the result in the output.

Parameters
vw0One-dimensional view over the first input.
vw1One-dimensional view over the second input.
vw2One-dimensional view over the output.
funcBinary function which is applied to all of the input elements.

This algorithm mutates the output view only.

◆ fill() [2/2]

template<typename View >
void stapl::prototype::fill ( View &  vw,
typename View::value_type  value 
)

Assigns the given value to the elements of the input view.

Parameters
vwOne-dimensional view of the input.
valueThe value to fill into the input.

This algorithm mutates the input view.

◆ for_each() [2/2]

template<typename View0 , typename Function >
Function stapl::prototype::for_each ( View0 const &  vw0,
Function  func 
)

Applies the given functor to all of the elements in the input.

Parameters
vw0One-dimensional view over the input.
funcUnary functor to apply to the elements.
Returns
The functor that was passed as input.

This algorithm will mutate the input view.

◆ iota()

template<typename View0 >
void stapl::iota ( View0 const &  view,
typename View0::value_type const &  value 
)

Initializes the elements of the view such that the first element is assigned value, the next element value+1, etc.

Parameters
viewA one-dimensional view over elements of a numeric type that are going to be initialized.
valueThe first value in the sequence assigned to the elements of the input view.
Note
This algorithm is defined in the standard as a numeric algorithm. It is included in the generating algorithms here because it behaves like a generating algorithm that requires that the view's element type is numeric.