本文整理汇总了C++中pred函数的典型用法代码示例。如果您正苦于以下问题:C++ pred函数的具体用法?C++ pred怎么用?C++ pred使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pred函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
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};
}
示例2: find_hyp_core
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>>();
}
示例3: test_adjacent_find_async
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);
}
示例4: group_helper
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>{}
);
}
示例5: operator
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};
}
示例6: GameTasks
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;
}
示例7: trimRightIf
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());
}
示例8: pred
//---------------------------------------------------------------------------
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;
}
示例9: int
/* 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é */
}
示例10: steer
// 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;
}
示例11: operator
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;
}
示例12: FallbackLoad
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);
}
}
示例13: pred
/// 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;
}
示例14: biconnected_components
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);
}
示例15: condition_test_waits
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();
}