本文整理汇总了C++中PacketQueue::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketQueue::erase方法的具体用法?C++ PacketQueue::erase怎么用?C++ PacketQueue::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketQueue
的用法示例。
在下文中一共展示了PacketQueue::erase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_ack
void ReliabilitySystem::process_ack(unsigned int ack, unsigned int ack_bits,
PacketQueue & pending_ack_queue, PacketQueue & acked_queue,
std::vector<unsigned int> & acks, unsigned int & acked_packets,
float & rtt, unsigned int max_sequence)
{
if (pending_ack_queue.empty())
return;
PacketQueue::iterator itor = pending_ack_queue.begin();
while (itor != pending_ack_queue.end()) {
bool acked = false;
if (itor->sequence == ack) {
acked = true;
} else if (!sequence_more_recent(itor->sequence, ack, max_sequence)) {
int bit_index = bit_index_for_sequence(itor->sequence, ack, max_sequence);
if (bit_index <= 31)
acked = (ack_bits >> bit_index) & 1;
}
if (acked) {
rtt += (itor->time - rtt) * 0.1f;
acked_queue.insert_sorted(*itor, max_sequence);
acks.push_back(itor->sequence);
acked_packets++;
itor = pending_ack_queue.erase(itor);
} else {
++itor;
}
}