TargetContainer map( SourceRange &&_source, Function const &_function ) { TargetContainer result; fcppt::algorithm::detail::map_reserve( result, _source ); for( fcppt::algorithm::range_element_type< SourceRange > element : _source ) result.insert( result.end(), _function( element ) ); return result; }
void delAll(TargetContainer& geoms) { for (typename TargetContainer::const_iterator i = geoms.begin(), e = geoms.end(); i != e; ++i) { Geom* g = dynamic_cast<Geom*>(*i); delete g; } }
static void unsplit( const openmp_state< typename TargetContainer::value_type > &from , TargetContainer &to ) { // resize target size_t total_size = 0; for(size_t i = 0 ; i < from.size() ; i++) total_size += from[i].size(); to.resize( total_size ); // copy parts typename TargetContainer::iterator out = to.begin(); for(size_t i = 0 ; i < from.size() ; i++) out = std::copy(from[i].begin(), from[i].end(), out); }
TargetContainer map_optional( Source &&_source, Function const &_function ) { TargetContainer result; for( fcppt::algorithm::range_element_type< Source > element : _source ) { auto result_element( _function( element ) ); static_assert( fcppt::is_optional< typename std::decay< decltype( result_element ) >::type >::value, "map_optional requires a function that returns an optional" ); if( result_element.has_value() ) result.insert( result.end(), std::move( result_element.get_unsafe() ) ); } return result; }
void push_back_right(TargetContainer& x, const SourceContainer& y) { // x.insert( x.end(), y.begin(), y.end() ); int n = y.size(); for (int i = 0; i < n; i++) { x.push_back(-y[i] - 1); } }
void push_back( TargetContainer& x, const SourceContainer& y ){ x.insert( x.end(), y.begin(), y.end() ) ; }