Example #1
0
 std::pair<I1, I2>
 operator()(I1 begin1, S1 end1, I2 begin2, C pred_ = C{}, P1 proj1_ = P1{},
     P2 proj2_ = P2{}) const
 {
     auto &&pred = as_function(pred_);
     auto &&proj1 = as_function(proj1_);
     auto &&proj2 = as_function(proj2_);
     for(; begin1 != end1; ++begin1, ++begin2)
         if(!pred(proj1(*begin1), proj2(*begin2)))
             break;
     return {begin1, begin2};
 }
Example #2
0
static optional<pair<expr, unsigned>> find_hyp_core(expr const & meta, F && pred) {
    expr const * it = &meta;
    unsigned i = 0;
    while (is_app(*it)) {
        expr const & h = app_arg(*it);
        if (pred(h))
            return some(mk_pair(h, i));
        i++;
        it = &app_fn(*it);
    }
    return optional<pair<expr, unsigned>>();
}
void test_adjacent_find_async(ExPolicy&& policy,
    hpx::partitioned_vector<T>& xvalues)
{
    auto result =
        hpx::parallel::adjacent_find(policy, xvalues.begin(), xvalues.end())
            .get();
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 31);

    result = hpx::parallel::adjacent_find(policy, xvalues.begin(),
        xvalues.end(), pred()).get();
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 4);
}
Example #4
0
 static constexpr auto
 group_helper(Xs&& xs, Pred&& pred, std::index_sequence<0, i...>) {
     using info = detail::group_indices<
         hana::value<decltype(
             pred(hana::at_c<i - 1>(static_cast<Xs&&>(xs)),
                  hana::at_c<i>(static_cast<Xs&&>(xs)))
         )>()...
     >;
     return info::template finish<S>(static_cast<Xs&&>(xs),
         std::make_index_sequence<info::n_groups>{}
     );
 }
 tagged_pair<tag::in1(I1), tag::in2(I2)>
 operator()(I1 begin1, S1 end1, I2 begin2, S2 end2, C pred_ = C{}, P1 proj1_ = P1{},
     P2 proj2_ = P2{}) const
 {
     auto &&pred = as_function(pred_);
     auto &&proj1 = as_function(proj1_);
     auto &&proj2 = as_function(proj2_);
     for(; begin1 != end1 &&  begin2 != end2; ++begin1, ++begin2)
         if(!pred(proj1(*begin1), proj2(*begin2)))
             break;
     return {begin1, begin2};
 }
Example #6
0
CGameTask*	CGameTaskManager::GiveGameTaskToActor(CGameTask* t, u32 timeToComplete, bool bCheckExisting)
{
	if(bCheckExisting && HasGameTask(t->m_ID)) return NULL;
	m_flags.set					(eChanged, TRUE);

	GameTasks().push_back				(SGameTaskKey(t->m_ID) );
	GameTasks().back().game_task			= t;
	t->m_ReceiveTime				= Level().GetGameTime();
	t->m_TimeToComplete				= t->m_ReceiveTime + timeToComplete;

	
	std::sort						(GameTasks().begin(), GameTasks().end(), task_prio_pred);

	ARTICLE_VECTOR& article_vector = Actor()->encyclopedia_registry->registry().objects();


	SGameTaskObjective	*obj = NULL;
	for (u32 i = 0; i < t->m_Objectives.size(); ++i){
		obj = &t->m_Objectives[i];
		if(obj->article_id.size()){
		FindArticleByIDPred pred(obj->article_id);
		if( std::find_if(article_vector.begin(), article_vector.end(), pred) == article_vector.end() ){
			CEncyclopediaArticle article;
			article.Load(obj->article_id);
			article_vector.push_back(ARTICLE_DATA(obj->article_id, Level().GetGameTime(), article.data()->articleType));
			}
		}

		if(obj->object_id!=u16(-1) && obj->map_location.size() && obj->def_location_enabled){
			CMapLocation* ml =	Level().MapManager().AddMapLocation(obj->map_location, obj->object_id);
			if(obj->map_hint.size())	ml->SetHint(obj->map_hint);
			ml->DisablePointer			();
			ml->SetSerializable			(true);
		}
	}
	CGameTask* _at = ActiveTask();
	if	( (NULL==_at) || (_at->m_priority > t->m_priority) )
	{
		SetActiveTask(t->m_ID, 1);
	}


	//установить флажок необходимости прочтения тасков в PDA
	if(HUD().GetUI()){
		CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
		if(pGameSP) 
			pGameSP->PdaMenu->PdaContentsChanged	(pda_section::quests);
	}
	if(true /*t->m_ID!="user_task"*/)
		t->Objective(0).ChangeStateCallback();

	return t;
}
Example #7
0
  void trimRightIf(std::string& str, P pred) {
    std::string::iterator i = str.end();

    for (; i != str.begin();) {
      if (!pred(*(--i))) {
	++i;
	break;
      }
    }
        
    str.erase(i, str.end());
  }
Example #8
0
//---------------------------------------------------------------------------
void tTVPLayerManager::ReleaseTouchCapture( tjs_uint32 id )
{
	FindTouchID pred( id );
	std::vector<tTVPTouchCaptureLayer>::iterator itr = std::find_if( TouchCapture.begin(), TouchCapture.end(), pred );
	if( itr != TouchCapture.end() )
	{
		tTJSNI_BaseLayer* old = itr->Owner;
		if( old && old->Owner ) old->Owner->Release();
		TouchCapture.erase(itr);
	}
	if( ReleaseTouchCaptureIDMark == (tjs_int64)id ) ReleaseTouchCaptureIDMark = -1;
}
Example #9
0
/* slist_find -- Trouve le premier élément de la liste égal à item
 * (d'après le prédicat pred) et positionne le pointeur de liste dessus.
 * Renvoie un pointeur sur son son contenu.
 * Si l'élément n'a pas pu ^etre trouvé, renvoie NULL.
 * Complexité: O(longueur(list)*C(pred))
 */
void *slist_find(SList *list, void *item, int (*pred)(void *, void *))
{
  assert((list != NULL) && (pred != NULL));
  if (slist_empty(list)) return NULL;

  for (slist_reset(list); list->current != NULL; slist_next(list))
    if (pred(slist_current(list), item)) break;
  if (list->current != NULL)
    return list->current->item; /* Trouvé */
  else
    return NULL;                /* Pas trouvé */
}
Example #10
0
// Separation
// Keeps boids from getting too close to one another
Pvector Boid::Separation(vector<Boid> boids)
{
	// Distance of field of vision for separation between boids
	float desiredseparation = desSep;
	Pvector steer(0, 0);
	int count = 0;
	// For every boid in the system, check if it's too close
	for (int i = 0; i < boids.size(); i++) {
		// Calculate distance from current boid to boid we're looking at
		float d = location.distance(boids[i].location);
		// If this is a fellow boid and it's too close, move away from it
		if ((d > 0) && (d < desiredseparation)) {
			Pvector diff(0, 0);
			diff = diff.subTwoVector(location, boids[i].location);
			diff.normalize();
			diff.divScalar(d);      // Weight by distance
			steer.addVector(diff);
			count++;
		}
		// If current boid is a predator and the boid we're looking at is also
		// a predator, then separate only slightly
		if ((d > 0) && (d < desSep) && predatorStatus == true
			&& boids[i].predatorStatus == true) {
			Pvector pred2pred(0, 0);
			pred2pred = pred2pred.subTwoVector(location, boids[i].location);
			pred2pred.normalize();
			pred2pred.divScalar(d);
			steer.addVector(pred2pred);
			count++;
		}
		// If current boid is not a predator, but the boid we're looking at is
		// a predator, then create a large separation Pvector
		else if ((d > 0) && (d < desiredseparation + 70) && boids[i].predatorStatus == true) {
			Pvector pred(0, 0);
			pred = pred.subTwoVector(location, boids[i].location);
			pred.mulScalar(900);
			steer.addVector(pred);
			count++;
		}
	}
	// Adds average difference of location to acceleration
	if (count > 0)
		steer.divScalar(static_cast<float>(count));
	if (steer.magnitude() > 0) {
		// Steering = Desired - Velocity
		steer.normalize();
		steer.mulScalar(maxSpeed);
		steer.subVector(velocity);
		steer.limit(maxForce);
	}
	return steer;
}
Example #11
0
 I
 operator()(I begin, S end, C pred_ = C{}, P proj_ = P{}) const
 {
     auto &&pred = as_function(pred_);
     auto &&proj = as_function(proj_);
     if(begin == end)
         return begin;
     auto next = begin;
     for(; ++next != end; begin = next)
         if(pred(proj(*begin), proj(*next)))
             return begin;
     return next;
 }
Example #12
0
static void FallbackLoad(size_t width, size_t height, size_t depth,
                         const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
                         uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
    if (pred())
    {
        prefered(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
    }
    else
    {
        fallback(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
    }
}
Example #13
0
    /// INTERNAL ONLY
    match_results<BidiIter> const &operator ()(regex_id_type regex_id, size_type index = 0) const
    {
        // BUGBUG this is linear, make it O(1)
        static match_results<BidiIter> const s_null;

        regex_id_filter_predicate<BidiIter> pred(regex_id);
        typename nested_results_type::const_iterator
            begin = this->nested_results_.begin()
          , end = this->nested_results_.end()
          , cur = detail::find_nth_if(begin, end, index, pred);

        return (cur == end) ? s_null : *cur;
    }
Example #14
0
 std::pair<std::size_t, OutputIterator>
 biconnected_components(const Graph & g, ComponentMap comp,
                        OutputIterator out, DiscoverTimeMap discover_time,
                        LowPointMap lowpt, VertexIndexMap index_map)
 {
   typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
   std::vector<vertex_t> pred(num_vertices(g));
   vertex_t vert = graph_traits<Graph>::null_vertex();
   return biconnected_components
            (g, comp, out, discover_time, lowpt,
             make_iterator_property_map(pred.begin(), index_map, vert),
             index_map);
 }
Example #15
0
void condition_test_waits(condition_test_data* data)
{
    boost::mutex::scoped_lock lock(data->mutex);
    BOOST_CHECK(lock ? true : false);

    // Test wait.
    while (data->notified != 1)
        data->condition.wait(lock);
    BOOST_CHECK(lock ? true : false);
    BOOST_CHECK_EQUAL(data->notified, 1);
    data->awoken++;
    data->condition.notify_one();

    // Test predicate wait.
    data->condition.wait(lock, cond_predicate(data->notified, 2));
    BOOST_CHECK(lock ? true : false);
    BOOST_CHECK_EQUAL(data->notified, 2);
    data->awoken++;
    data->condition.notify_one();

    // Test timed_wait.
    boost::xtime xt = delay(10);
    while (data->notified != 3)
        data->condition.timed_wait(lock, xt);
    BOOST_CHECK(lock ? true : false);
    BOOST_CHECK_EQUAL(data->notified, 3);
    data->awoken++;
    data->condition.notify_one();

    // Test predicate timed_wait.
    xt = delay(10);
    cond_predicate pred(data->notified, 4);
    BOOST_CHECK(data->condition.timed_wait(lock, xt, pred));
    BOOST_CHECK(lock ? true : false);
    BOOST_CHECK(pred());
    BOOST_CHECK_EQUAL(data->notified, 4);
    data->awoken++;
    data->condition.notify_one();
}
Example #16
0
 static I impl(I begin, S end, C pred_, P proj_, concepts::ForwardIterator*)
 {
     auto && pred = invokable(pred_);
     auto && proj = invokable(proj_);
     while(true)
     {
         if(begin == end)
             return begin;
         if(!pred(proj(*begin)))
             break;
         ++begin;
     }
     for(I p = begin; ++p != end;)
     {
         if(pred(proj(*p)))
         {
             ranges::iter_swap(begin, p);
             ++begin;
         }
     }
     return begin;
 }
Example #17
0
 I operator()(I const begin_, iterator_difference_t<I> const n_, C pred_ = C{}, P proj_ = P{}) const
 {
     RANGES_ASSERT(0 <= n_);
     auto &&pred = as_function(pred_);
     auto &&proj = as_function(proj_);
     iterator_difference_t<I> p = 0, c = 1;
     I pp = begin_;
     while(c < n_)
     {
         I cp = begin_ + c;
         if(pred(proj(*pp), proj(*cp)))
             return cp;
         ++c;
         ++cp;
         if(c == n_ || pred(proj(*pp), proj(*cp)))
             return cp;
         ++p;
         ++pp;
         c = 2 * p + 1;
     }
     return begin_ + n_;
 }
Example #18
0
void *table_search(table_t *table, int (*pred)(void *)) {
  int i;
  void *cur;
  for (i = 0; i < table->n_elts; i++) {
    cur = table->data + (i * table->elt_len);
    switch (pred(cur)) {
    case 1: return cur;
    case -1: return NULL;
    default: continue;
    }
  }
  return NULL;
}
Example #19
0
  mismatch(I1 first1, S1 last1, I2 first2, Pred pred_ = Pred{},
           Proj1 proj1_ = Proj1{}, Proj2 proj2_ = Proj2{}) {
    auto&& pred = __stl2::as_function(pred_);
    auto&& proj1 = __stl2::as_function(proj1_);
    auto&& proj2 = __stl2::as_function(proj2_);

    for (; first1 != last1; ++first1, ++first2) {
      if (!pred(proj1(*first1), proj2(*first2))) {
        break;
      }
    }
    return {first1, first2};
  }
Example #20
0
Label GPC::predict(const SparseVector& features) {
	vector<double> feature_vec = to_dense_vector(features);

	if(predictor != NULL) {
		CMatrix ft(1, input_dim, feature_vec);
		CMatrix pred(1,1);

		predictor->out(pred, ft);

		return pred.getVal(0,0);
	}
	return 0;
}
void condition_test_waits(condition_test_data<Condition, Mutex>* data)
{
    boost::interprocess::scoped_lock<Mutex>
      lock(data->mutex);
    BOOST_INTERPROCESS_CHECK(lock ? true : false);

    // Test wait.
    while (data->notified != 1)
        data->condition.wait(lock);
    BOOST_INTERPROCESS_CHECK(lock ? true : false);
    BOOST_INTERPROCESS_CHECK(data->notified == 1);
    data->awoken++;
    data->condition.notify_one();

    // Test predicate wait.
    data->condition.wait(lock, cond_predicate(data->notified, 2));
    BOOST_INTERPROCESS_CHECK(lock ? true : false);
    BOOST_INTERPROCESS_CHECK(data->notified == 2);
    data->awoken++;
    data->condition.notify_one();

    // Test timed_wait.
    while (data->notified != 3)
        data->condition.timed_wait(lock, ptime_delay(5));
    BOOST_INTERPROCESS_CHECK(lock ? true : false);
    BOOST_INTERPROCESS_CHECK(data->notified == 3);
    data->awoken++;
    data->condition.notify_one();

    // Test predicate timed_wait.
    cond_predicate pred(data->notified, 4);
    bool ret = data->condition.timed_wait(lock, ptime_delay(5), pred);
    BOOST_INTERPROCESS_CHECK(ret);(void)ret;
    BOOST_INTERPROCESS_CHECK(lock ? true : false);
    BOOST_INTERPROCESS_CHECK(pred());
    BOOST_INTERPROCESS_CHECK(data->notified == 4);
    data->awoken++;
    data->condition.notify_one();
}
Example #22
0
obj dequeue_pop_back( obj deq )
{
  obj item, newb, oldb = DEQ_BACK(deq);
  assert_ne(deq, "dequeue-pop-back!");
  newb = pred( deq, oldb );
  SET_DEQ_BACK( deq, newb );
  item = gvec_ref( DEQ_STATE(deq), FXWORDS_TO_RIBYTES(newb) );
  /* clear the now-unused position in case there is a GC liveness issue
   * (ie, I was seeing annoying latencies finalizing threads in the
   * new threads system)
   */
  gvec_write_non_ptr( DEQ_STATE(deq), FXWORDS_TO_RIBYTES(newb), FALSE_OBJ );
  return item;
}
Example #23
0
File: vector.c Project: bendst/cu
void *vector_find(const vector_t *v, const void *key, bool (*pred)(
                             const void *,
                             const void *)) {
    assert(v);
    assert(key);
    void *item = NULL;
    for (size_t i = 0; i < v->count; i++) {
        item = vector_get(v, i);
        if (pred(key, item)) {
            return item;
        }
    }
    return NULL;
}
T* filter (T arr[], size_t n, bool (*pred) (T), size_t& newSize)
{
    size_t count = 0;
    for (size_t i = 0; i < n; i++)
    {
        if (pred(arr[i]))
        {
            count++;
        }
    }
    T *result = new T[count];
    count = 0;
    for (size_t i = 0; i < n; i++)
    {
        if (pred(arr[i]))
        {   
            result[count] = arr[i];
            count++;
        }
    }
    newSize = count;
    return result;
}
Example #25
0
 static constexpr decltype(auto)
 find_helper(Xs&& xs, Pred&& pred,
             detail::std::integral_constant<Size, i>,
             detail::std::false_type)
 {
     auto cond = pred(detail::std::forward<Xs>(xs)[i + 1]);
     constexpr bool truth_value = hana::if_(hana::value(cond), true, false);
     return find_helper(
         detail::std::forward<Xs>(xs),
         detail::std::forward<Pred>(pred),
         detail::std::integral_constant<Size, i + 1>{},
         detail::std::integral_constant<bool, truth_value>{}
     );
 }
Example #26
0
void EraseIf(C& cont, const P& pred)
{
    for (typename C::iterator p = cont.begin(); p != cont.end(); )
    {
        if ( pred(*p) ) {
            typename C::iterator p_next = p;
	    ++p_next;
            cont.erase(p);
	    p = p_next;
        }
        else
            ++p;
    }
}
void Block::dump_head( const Block_Array *bbs ) const { 
  // Print the basic block
  dump_bidx(this);
C2OUT->print(": #\t");

  // Print the incoming CFG edges and the outgoing CFG edges
  for( uint i=0; i<_num_succs; i++ ) {
    non_connector_successor(i)->dump_bidx(_succs[i]);
C2OUT->print(" ");
  }
C2OUT->print("<- ");
  if( head()->is_block_start() ) {
    for (uint i=1; i<num_preds(); i++) {
      Node *s = pred(i);
      if (bbs) {
        Block *p = (*bbs)[s->_idx];
        p->dump_pred(bbs, p);
      } else {
        while (!s->is_block_start()) 
          s = s->in(0);
C2OUT->print("N%d ",s->_idx);
      }
    }
  } else 
C2OUT->print("BLOCK HEAD IS JUNK  ");

  // Print loop, if any
  const Block *bhead = this;    // Head of self-loop
  Node *bh = bhead->head();
  if( bbs && bh->is_Loop() && !head()->is_Root() ) {
    LoopNode *loop = bh->as_Loop();
    const Block *bx = (*bbs)[loop->in(LoopNode::LoopBackControl)->_idx];
    while (bx->is_connector()) {
      bx = (*bbs)[bx->pred(1)->_idx];
    }
C2OUT->print("\tLoop: B%d-B%d ",bhead->_pre_order,bx->_pre_order);
    // Dump any loop-specific bits, especially for CountedLoops.
loop->dump_spec(C2OUT);
  }
C2OUT->print(" Freq: %g",_freq);
  if( Verbose ) {
C2OUT->print(" IDom: %d/#%d",_idom?_idom->_pre_order:0,_dom_depth);
C2OUT->print(" RegPressure: %d",_reg_pressure);
C2OUT->print(" IHRP Index: %d",_ihrp_index);
C2OUT->print(" FRegPressure: %d",_freg_pressure);
C2OUT->print(" FHRP Index: %d",_fhrp_index);
  }
C2OUT->cr();
}
//------------------------------is_uncommon------------------------------------
// True if block is low enough frequency or guarded by a test which 
// mostly does not go here.
bool Block::is_uncommon( Block_Array &bbs ) const {
  // Initial blocks must never be moved, so are never uncommon.
  if (head()->is_Root() || head()->is_Start())  return false;

  // Check for way-low freq
  if( _freq < BLOCK_FREQUENCY(0.00001f) ) return true;

  // Look for code shape indicating uncommon_trap or slow path
  if (has_uncommon_code()) return true;

  const float epsilon = 0.05f;
  const float guard_factor = PROB_UNLIKELY_MAG(4) / (1.f - epsilon);
  uint uncommon_preds = 0;
  uint freq_preds = 0;
  uint uncommon_for_freq_preds = 0;

  for( uint i=1; i<num_preds(); i++ ) {
    Block* guard = bbs[pred(i)->_idx];
    // Check to see if this block follows its guard 1 time out of 10000
    // or less. 
    //
    // See list of magnitude-4 unlikely probabilities in cfgnode.hpp which
    // we intend to be "uncommon", such as slow-path TLE allocation, 
    // predicted call failure, and uncommon trap triggers.
    //
    // Use an epsilon value of 5% to allow for variability in frequency 
    // predictions and floating point calculations. The net effect is
    // that guard_factor is set to 9500.
    //
    // Ignore low-frequency blocks.
    // The next check is (guard->_freq < 1.e-5 * 9500.).
    if(guard->_freq*BLOCK_FREQUENCY(guard_factor) < BLOCK_FREQUENCY(0.00001f)) {
      uncommon_preds++;
    } else {
      freq_preds++;
      if( _freq < guard->_freq * guard_factor ) {
        uncommon_for_freq_preds++;
      }
    }
  }
  if( num_preds() > 1 &&
      // The block is uncommon if all preds are uncommon or
      (uncommon_preds == (num_preds()-1) ||
      // it is uncommon for all frequent preds.
       uncommon_for_freq_preds == freq_preds) ) {
    return true; 
  }
  return false;
}
Example #29
0
    void mk_coalesce::merge_rules(rule_ref& tgt, rule const& src) {
        SASSERT(same_body(*tgt.get(), src));
        m_sub1.reset();
        m_sub2.reset();
        m_idx = 0;
        app_ref pred(m), head(m);
        expr_ref fml1(m), fml2(m), fml(m);
        app_ref_vector tail(m);
        ptr_vector<sort> sorts1, sorts2;
        expr_ref_vector conjs1(m), conjs(m);
        rule_ref res(rm);
        bool_rewriter bwr(m);
        svector<bool> is_neg;
        tgt->get_vars(sorts1);
        src.get_vars(sorts2);

        mk_pred(head, src.get_head(), tgt->get_head()); 
        for (unsigned i = 0; i < src.get_uninterpreted_tail_size(); ++i) {
            mk_pred(pred, src.get_tail(i), tgt->get_tail(i));
            tail.push_back(pred);
            is_neg.push_back(src.is_neg_tail(i));
        }           
        extract_conjs(m_sub1, src, fml1);
        extract_conjs(m_sub2, *tgt.get(),  fml2);
        bwr.mk_or(fml1, fml2, fml);
        SASSERT(is_app(fml));
        tail.push_back(to_app(fml));
        is_neg.push_back(false);
        res = rm.mk(head, tail.size(), tail.c_ptr(), is_neg.c_ptr(), tgt->name());
        if (m_ctx.generate_proof_trace()) {
            src.to_formula(fml1);
            tgt->to_formula(fml2);
            res->to_formula(fml);
#if 0
            sort* ps = m.mk_proof_sort();
            sort* domain[3] = { ps, ps, m.mk_bool_sort() };
            func_decl* merge = m.mk_func_decl(symbol("merge-clauses"), 3, domain, ps);  // TBD: ad-hoc proof rule
            expr* args[3] = { m.mk_asserted(fml1), m.mk_asserted(fml2), fml };
            // ...m_pc->insert(m.mk_app(merge, 3, args));
#else
            svector<std::pair<unsigned, unsigned> > pos;
            vector<expr_ref_vector> substs;
            proof* p = src.get_proof();
            p = m.mk_hyper_resolve(1, &p, fml, pos, substs);
            res->set_proof(m, p);
#endif
        }
        tgt = res;
    }
Example #30
0
 static I impl(I begin, S end_, C pred_, P proj_, concepts::BidirectionalIterator*)
 {
     auto && pred = invokable(pred_);
     auto && proj = invokable(proj_);
     I end = next_to(begin, end_);
     while(true)
     {
         while(true)
         {
             if(begin == end)
                 return begin;
             if(!pred(proj(*begin)))
                 break;
             ++begin;
         }
         do
         {
             if(begin == --end)
                 return begin;
         } while(!pred(proj(*end)));
         ranges::iter_swap(begin, end);
         ++begin;
     }
 }