void Heap<T, Compare>::FilterDown (int i) { int currentpos, childpos; T target; currentpos=i; childpos=2*i+1; target=m_pdata[i]; while (childpos<curr_size) { if ( (childpos+1<curr_size) && m_f(m_pdata[childpos+1],m_pdata[childpos])) { ++childpos; } if (m_f(target,m_pdata[childpos])) { break; } else { std::swap(m_pdata[currentpos], m_pdata[childpos]); currentpos=childpos; childpos=2*currentpos+1; } } m_pdata[currentpos]=target; }
void GridMeterScalarFunc::measure(data_sp data) { Phase *phase = ((Simulation*) M_GRID_AVERAGER->parent())->phase(); vector<double> *moments = data->vectorDoubleByOffset(m_moment_o).value(); int n_cells = M_GRID_AVERAGER->nCells(); moments->resize(n_cells); FOR_EACH_FREE_PARTICLE_C (phase, m_colour, int index = M_GRID_AVERAGER->location(c, __iSLFE->mySlot); int n = M_GRID_AVERAGER->nParticles(c, index); if (n) { // the argument of the sin is a scalar product double e; m_f(&e, __iSLFE); e*= __iSLFE->tag.doubleByOffset(m_scalar_o); if(m_moment != 1) { double temp = e; for(size_t pow = 2; pow <= m_moment; ++pow) e*=temp; } /* fixme!!! Slow! Better divide only once per cell. */ (*moments)[index] += e/n; } );
void CBC::operator()(NTupleRW<symbol>& Vec, int mode /*=Encrypt*/) { int len=m_f.GetSize(); if (mode==Encrypt) { //Vec=Vec^m_lastblock; for (int j=0;j<len;j++) Vec[j]=Vec[j]^m_lastblock[j]; m_f(Vec,Cipher::Encrypt); Copy(m_lastblock,Vec,len); } else { // Decrypt static Array<symbol,symbol> tmp(len); Copy(tmp,Vec,len); m_f(Vec,Cipher::Decrypt); //Vec=Vec^m_lastblock; for (int j=0;j<len;j++) Vec[j]=Vec[j]^m_lastblock[j]; Copy(m_lastblock,tmp,len); } }
void for_each_level_fn::apply(level const & l) { if (!m_f(l)) return; switch (l.kind()) { case level_kind::Succ: apply(succ_of(l)); break; case level_kind::Max: case level_kind::IMax: apply(to_max_core(l).m_lhs); apply(to_max_core(l).m_rhs); break; case level_kind::Zero: case level_kind::Param: case level_kind::Meta: case level_kind::Global: break; } }
void draw_lines() const{ T dist = (m_r2 - m_r1) / m_count; T r = m_r1; Open_polyline op; for(int i = 0; i < m_count; ++i) { op.add(Point(m_orig.x + int(r * m_xscale), m_orig.y - int(m_f(r) * m_yscale))); r += dist; } op.draw_lines(); }
Seq<Shrinkables<T>> shrinkElements(const Shrinkables<T> &shrinkables) const { using Key = Decay<typename std::result_of<F(T)>::type>; const auto keys = std::make_shared<std::set<Key>>(); for (const auto &shrinkable : shrinkables) { keys->insert(m_f(shrinkable.value())); } return shrink::eachElement(shrinkables, [=](const Shrinkable<T> &s) { const auto valueKey = m_f(s.value()); return seq::filter( s.shrinks(), [=](const Shrinkable<T> &shrink) { const auto shrinkKey = m_f(shrink.value()); return (!(valueKey < shrinkKey) && !(shrinkKey < valueKey)) || keys->count(shrinkKey) == 0; }); }); }
void operator()( Wt::WContainerWidget* pcw ) { std::cout << "callback "; auto pMemberTop( new Wt::WText( "member top" ) ); pMemberTop->setStyleClass( "MemmberTop" ); pcw->addWidget( pMemberTop ); m_f( pcw ); auto pMemberBottom( new Wt::WText( "member bottom" ) ); pMemberBottom->setStyleClass( "MemberBottom" ); pcw->addWidget( pMemberBottom ); }
double operator()(const double x, const double y) const noexcept { const auto co_double = m_f(x,y); const Plane::Coordinat3D co_apfloat( apfloat(boost::geometry::get<0>(co_double)), apfloat(boost::geometry::get<1>(co_double)), apfloat(boost::geometry::get<2>(co_double)) ); const auto error_apfloat = m_plane.CalcError(co_apfloat); return Geometry().ToDoubleSafe(error_apfloat); //return m_plane.CalcError(m_f(x,y)); }
void FeistelCipher::operator()(NTupleRW<symbol>& Vec, int mode /*=Encrypt*/) const { m_Init(Vec); if (m_f.GetSize()==1) { //SubArray<symbol> R(Vec,1,1); for (int i=0;i<m_Rounds;i++) { symbol t=Vec[1]; //m_f(R,mode==Decrypt?m_Rounds-1-i:i); Vec[1]=m_f(Vec[1],mode==Decrypt?m_Rounds-1-i:i); Vec[1]=Vec[1]^Vec[0]; Vec[0]=t; } #if !defined(_MSC_VER) || _MSC_VER <= 1200 swap(Vec[0],Vec[1]); #else std::swap(Vec[0],Vec[1]); #endif } else { int len=m_f.GetSize(); //SubArray L(Vec,0,len); // benutze Vec stattdessen, ist schneller NTupleRW<symbol>& L=Vec; SubArray<symbol> R(Vec,len,len); static Array<symbol,symbol> t(len); for (int i=0;i<m_Rounds;i++) { //symbol t=Vec[1]; Copy(t,R,len); //for (int j=0;j<len;j++) t[j]=R[j]; m_f(R,mode==Decrypt?m_Rounds-1-i:i); //Vec[1]=Vec[1]^Vec[0]; for (int j=0;j<len;j++) R[j]=R[j]^L[j]; //Vec[0]=t; Copy(L,t,len); //for (int j=0;j<len;j++) L[j]=t[j]; } #if !defined(_MSC_VER) || _MSC_VER <= 1200 for (int j=0;j<len;j++) swap(Vec[j],Vec[j+len]); #else for (int j=0;j<len;j++) std::swap(Vec[j],Vec[j+len]); #endif } m_End(Vec); }
void compute_value() { if ( m_first == m_last) { m_processed_last = true; return; } if ( m_f( m_val, *m_first, m_idx)) { ++m_idx; return; } else ++m_first; }
level replace_level_fn::apply(level const & l) { optional<level> r = m_f(l); if (r) return *r; switch (l.kind()) { case level_kind::Succ: return update_succ(l, apply(succ_of(l))); case level_kind::Max: case level_kind::IMax: return update_max(l, apply(to_max_core(l).m_lhs), apply(to_max_core(l).m_rhs)); case level_kind::Zero: case level_kind::Param: case level_kind::Meta: case level_kind::Global: return l; } lean_unreachable(); // LCOV_EXCL_LINE }
Shrinkables<T> generateElements(const Random &random, int size, std::size_t count, const Gen<T> &gen) const { using Key = Decay<typename std::result_of<F(T)>::type>; std::set<Key> values; return detail::generateShrinkables(random, size, count, gen, [&](const Shrinkable<T> &s) { return values.insert(m_f(s.value())) .second; }); }
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Dynamic_Cast_Conversions &t_conversions) const { if (m_arity < 0 || params.size() == size_t(m_arity)) { if (test_guard(params, t_conversions)) { return m_f(params); } else { throw exception::guard_error(); } } else { throw exception::arity_error(static_cast<int>(params.size()), m_arity); } }
void compute_value() { if ( m_first == m_last) { m_processed_last = true; return; } iterator_type begin = m_first; while ( m_first != m_last) { iterator_type prev = m_first; ++m_first; if ( m_first == m_last) break; if ( !m_slicer( *prev, *m_first)) break; } m_f( m_val, begin, m_first); }
void EvolutionScreen::Finalize() { Textbox* main_frame = this->main_frame; Textbox* evolved = new Textbox(); bool learned_move = false; std::function<void(TextItem* s)> m_f = nullptr; for (int i = 0; i < 16; i++) { if (pokemon_to->learnset[i].level == 0) break; if (pokemon_to->learnset[i].level == pokemon->level) { m_f = PokemonUtils::LearnMove(evolved, pokemon, pokemon_to->learnset[i].move); learned_move = true; } } std::function<void(TextItem* s)> a = [m_f, evolved](TextItem* src) { evolved->CancelClose(); m_f(src); }; evolved->SetText(new TextItem(evolved, (!m_f ? [main_frame, evolved](TextItem* src) {evolved->Close(); main_frame->Close(); } : a), string(pokemon->nickname).append(pokestring(" evolved\ninto ")).append(pokemon_to->original_name).append(pokestring("!\t\t\t\t\t\t\a")))); main_frame->ShowTextbox(evolved, false); if (learned_move) { auto b = [evolved, main_frame, this](TextItem* s) { evolved->Close(true); main_frame->Close(); this->parent->Close(); }; evolved->SetCloseCallback(b); } pokemon->id = pokemon_to->id; pokemon->pokedex_index = pokemon_to->pokedex_index; pokemon->LoadStats(); unsigned int hp = pokemon->max_hp; pokemon->RecalculateStats(); pokemon->hp += pokemon->max_hp - hp; }
void Heap<T, Compare>::FilterUp (int i) { int currentpos, parentpos; T target; currentpos=i; parentpos=(i-1)/2; target=m_pdata[i]; while (currentpos) { if (!(m_f(m_pdata[currentpos],m_pdata[parentpos]))) { break; } else { std::swap(m_pdata[parentpos], m_pdata[currentpos]); currentpos=parentpos; parentpos=(currentpos-1)/2; } } m_pdata[currentpos]=target; }
void compute_value() { if ( m_first == m_last) { m_processed_last = true; return; } // FIXME for iterator categories > input_iterator // don't use any temporary m_val = m_init; while ( true) { src_value_type tmp = *m_first; m_f( m_val, tmp); ++m_first; if ( m_first != m_last) { if ( !m_slicer( tmp, *m_first)) // got to a new slice break; } else // got to the end break; } }
TaggedConstant operator()(const Tuple& k) { return m_f(k); }
std::shared_ptr<torrent_plugin> new_torrent(torrent_handle const& t, void* user) override { return m_f(t, user); }
typename super_t::reference dereference() const { return m_f(*this->base()); }
Real operator()(const S& row) { return -Real(m_f(row)); }
void cv::GCPUKernel::apply(GCPUContext &ctx) { GAPI_Assert(m_f); m_f(ctx); }
template <class T> output_proxy& operator=(const T& value) { m_f(value); return *this; }
virtual void exec() { m_f(); }
output_proxy& operator=(const T& value) { m_f(value); return *this; }
bool operator()(const wxChar* s1, const wxChar* s2) { return m_f(s1, s2) < 0; }
typename IteratorAdaptorT::reference dereference(const IteratorAdaptorT &iter) const { return m_f(*iter.base()); }
~ScopeExit() { m_f(); }
bool operator()(const wxString& s1, const wxString& s2) { return m_f(s1, s2) < 0; }
void Task::operator()() { m_f(); }