本文整理汇总了C++中std::deque::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::erase方法的具体用法?C++ deque::erase怎么用?C++ deque::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::erase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/** Update the console messages.
This function will remove messages that are overdue.
*/
void updateConsoleMessages(void)
{
// If there are no messages or we're on permanent (usually for scripts) then exit
if ((!getNumberConsoleMessages() && !InfoMessages.size()) || mainConsole.permanent)
{
return;
}
for (auto i = InfoMessages.begin(); i != InfoMessages.end();)
{
if (realTime - i->timeAdded > messageDuration)
{
i = InfoMessages.erase(i);
}
else
{
++i;
}
}
// Time to kill all expired ones
for (auto i = ActiveMessages.begin(); i != ActiveMessages.end();)
{
if (realTime - i->timeAdded > messageDuration)
{
i = ActiveMessages.erase(i);
}
else
{
++i;
}
}
}
示例2: next
void next(std::deque<std::deque<match_t *> > *last_round, std::deque<player_t *> &tournament_players) {
int half = tournament_players.size()/2;
/** "Rotates clockwise" */
tournament_players.insert(tournament_players.begin() + 1, tournament_players[half]);
tournament_players.erase(tournament_players.begin() + half + 1);
tournament_players.insert(tournament_players.end(), tournament_players[half]);
tournament_players.erase(tournament_players.begin() + half);
}
示例3: bad_erase_deque1
void bad_erase_deque1(std::deque<int> &D) {
auto i2 = D.cbegin(), i0 = i2++, i1 = i2++;
D.erase(i1);
*i0; // expected-warning{{Invalidated iterator accessed}}
*i1; // expected-warning{{Invalidated iterator accessed}}
*i2; // expected-warning{{Invalidated iterator accessed}}
}
示例4: remove
bool remove(std::deque<RHNode> &vec, RHNode &element)
{
std::deque<RHNode>::iterator it = std::find(vec.begin(), vec.end(), element);
if(it == vec.end())
return true;
vec.erase(it);
return true;
}
示例5: deactive
bool deactive(thread_control_block *tcb){
threads.erase(std::find(threads.begin(), threads.end(), tcb));
threads.push_back(tcb);
sem_post(&service_count);
int v;
sem_getvalue(&service_count, &v);
return true;
}
示例6: sliceToLimits
void UserPhotosSliceBuilder::sliceToLimits() {
auto aroundIt = ranges::find(_ids, _key.photoId);
auto removeFromBegin = (aroundIt - _ids.begin() - _limitBefore);
auto removeFromEnd = (_ids.end() - aroundIt - _limitAfter - 1);
if (removeFromEnd > 0) {
_ids.erase(_ids.end() - removeFromEnd, _ids.end());
_skippedAfter += removeFromEnd;
}
if (removeFromBegin > 0) {
_ids.erase(_ids.begin(), _ids.begin() + removeFromBegin);
if (_skippedBefore) {
*_skippedBefore += removeFromBegin;
}
} else if (removeFromBegin < 0 && (!_skippedBefore || *_skippedBefore > 0)) {
_insufficientPhotosAround.fire(_ids.empty() ? 0 : _ids.front());
}
}
示例7: EndSockWatch
void EndSockWatch(SOCKET sock) {
std::deque<SOCKET>::iterator it = std::find(
socketwatches.begin(),
socketwatches.end(),
sock
);
if (it != socketwatches.end())
socketwatches.erase(it);
}
示例8: remove_symbol
///Method to remove a symbol
bool remove_symbol(const char* symbol_name) {
for( typename std::deque<std::pair<std::string, T> >::iterator it = symbols.begin() ; it != symbols.end() ; it++ ){
if( it->first.compare(symbol_name) == 0 ){
symbols.erase(it);
return true;
}
}
return false;
}
示例9: popAt
T popAt(int index) {
if (index >= stacks.size()) { throw; }
std::stack<T> &stack = *(stacks.begin() + index);
T ret = stack.top(); stack.pop();
if (stack.size() == 0) {
stacks.erase(stacks.begin() + index);
}
return ret;
}
示例10: deleteTrailingZeros
void deleteTrailingZeros()
{
auto reverse_it = std::find_if(
pos_vec.rbegin(),
pos_vec.rend(),
[](int i) {return i != 0;} );
pos_vec.erase(reverse_it.base(),pos_vec.end());
};
示例11:
CInputReceiver::~CInputReceiver(void)
{
std::deque<CInputReceiver*>::iterator ri;
for(ri=inputReceivers.begin();ri!=inputReceivers.end();++ri){
if(*ri==this){
inputReceivers.erase(ri);
break;
}
}
}
示例12: processTask
void processTask(int position) {
auto task = tasks[position];
tasks.erase(tasks.begin() + position);
task->setTile(std::make_shared<Tile>(task->tileId(), s_projection, &task->source()));
pendingTiles = true;
processedCount++;
}
示例13: RemoveFromZoneList
void zZone::RemoveFromZoneList(void) {
std::deque<zZone *>::iterator pos_found =
std::find_if(
sz_Zones.begin(),
sz_Zones.end(),
std::bind2nd(
std::equal_to<zZone *>(),
this)
);
if(pos_found != sz_Zones.end())
sz_Zones.erase(pos_found);
}
示例14: while
std::vector<T> FlowMath::dequeToVector(std::deque<T>& deq) {
// convert the std::deque into a std::vector
//
std::vector<T> vec;
typename std::deque<T>::iterator it = deq.begin();
while (deq.empty() == false) {
vec.push_back(*it);
deq.erase(it);
it = deq.begin();
}
return vec;
}
示例15: Cleanup
/*
* Removes outdated challenges
* PRE: The caller has acquired a lock on mutex
*/
static void Cleanup()
{
auto now = Challenge::Clock::now();
challenges.erase(
std::remove_if( challenges.begin(), challenges.end(),
[&now]( const Challenge& challenge ) {
return !challenge.ValidAt( now );
}
),
challenges.end()
);
}