本文整理汇总了C++中datastructures::Queue::PushAtHead方法的典型用法代码示例。如果您正苦于以下问题:C++ Queue::PushAtHead方法的具体用法?C++ Queue::PushAtHead怎么用?C++ Queue::PushAtHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datastructures::Queue
的用法示例。
在下文中一共展示了Queue::PushAtHead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void StatisticsHistory::TimeAndValueQueue::ResizeSampleSet( int maxSamples, DataStructures::Queue<StatisticsHistory::TimeAndValue> &histogram, SHDataCategory dataCategory, Time timeClipStart, Time timeClipEnd )
{
histogram.Clear(_FILE_AND_LINE_);
if (maxSamples==0)
return;
Time timeRange = GetTimeRange();
if (timeRange==0)
return;
if (maxSamples==1)
{
StatisticsHistory::TimeAndValue tav;
tav.time = timeRange;
tav.val = GetRecentSum();
histogram.Push(tav, _FILE_AND_LINE_);
return;
}
Time interval = timeRange / maxSamples;
if (interval==0)
interval=1;
unsigned int dataIndex;
Time timeBoundary;
StatisticsHistory::TimeAndValue currentSum;
Time currentTime;
SHValueType numSamples;
Time endTime;
numSamples=0;
endTime = values[values.Size()-1].time;
dataIndex=0;
currentTime=values[0].time;
currentSum.val=0;
currentSum.time=values[0].time + interval / 2;
timeBoundary = values[0].time + interval;
while (timeBoundary <= endTime)
{
while (dataIndex < values.Size() && values[dataIndex].time <= timeBoundary)
{
currentSum.val += values[dataIndex].val;
dataIndex++;
numSamples++;
}
if (dataCategory==DC_CONTINUOUS)
{
if (dataIndex > 0 &&
dataIndex < values.Size() &&
values[dataIndex-1].time < timeBoundary &&
values[dataIndex].time > timeBoundary)
{
SHValueType interpolatedValue = Interpolate(values[dataIndex-1], values[dataIndex], timeBoundary);
currentSum.val+=interpolatedValue;
numSamples++;
}
if (numSamples > 1)
{
currentSum.val /= numSamples;
}
}
histogram.Push(currentSum, _FILE_AND_LINE_);
currentSum.time=timeBoundary + interval / 2;
timeBoundary += interval;
currentSum.val=0;
numSamples=0;
}
if ( timeClipStart!=0 && histogram.Size()>=1)
{
timeClipStart = histogram.Peek().time+timeClipStart;
if (histogram.PeekTail().time < timeClipStart)
{
histogram.Clear(_FILE_AND_LINE_);
}
else if (histogram.Size()>=2 && histogram.Peek().time < timeClipStart)
{
StatisticsHistory::TimeAndValue tav;
do
{
tav = histogram.Pop();
if (histogram.Peek().time == timeClipStart)
{
break;
}
else if (histogram.Peek().time > timeClipStart)
{
StatisticsHistory::TimeAndValue tav2;
tav2.val = StatisticsHistory::TimeAndValueQueue::Interpolate(tav, histogram.Peek(), timeClipStart);
tav2.time=timeClipStart;
histogram.PushAtHead(tav2, 0, _FILE_AND_LINE_);
break;
}
} while (histogram.Size()>=2);
}
}
if ( timeClipEnd!=0 && histogram.Size()>=1)
//.........这里部分代码省略.........
示例2: if
bool RPC4::CallBlocking( const char* uniqueID, RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, RakNet::BitStream *returnData )
{
RakNet::BitStream out;
out.Write((MessageID) ID_RPC_PLUGIN);
out.Write((MessageID) ID_RPC4_CALL);
out.WriteCompressed(uniqueID);
out.Write(true); // Blocking
if (bitStream)
{
bitStream->ResetReadPointer();
out.AlignWriteToByteBoundary();
out.Write(bitStream);
}
RakAssert(returnData);
RakAssert(rakPeerInterface);
ConnectionState cs;
cs = rakPeerInterface->GetConnectionState(systemIdentifier);
if (cs!=IS_CONNECTED && cs!=IS_LOOPBACK)
return false;
SendUnified(&out,priority,reliability,orderingChannel,systemIdentifier,false);
returnData->Reset();
blockingReturnValue.Reset();
gotBlockingReturnValue=false;
Packet *packet;
DataStructures::Queue<Packet*> packetQueue;
while (gotBlockingReturnValue==false)
{
// TODO - block, filter until gotBlockingReturnValue==true or ID_CONNECTION_LOST or ID_DISCONNECTION_NOTIFICXATION or ID_RPC_REMOTE_ERROR/RPC_ERROR_FUNCTION_NOT_REGISTERED
RakSleep(30);
packet=rakPeerInterface->Receive();
if (packet)
{
if (
(packet->data[0]==ID_CONNECTION_LOST || packet->data[0]==ID_DISCONNECTION_NOTIFICATION) &&
((systemIdentifier.rakNetGuid!=UNASSIGNED_RAKNET_GUID && packet->guid==systemIdentifier.rakNetGuid) ||
(systemIdentifier.systemAddress!=UNASSIGNED_SYSTEM_ADDRESS && packet->systemAddress==systemIdentifier.systemAddress))
)
{
// Push back to head in reverse order
rakPeerInterface->PushBackPacket(packet,true);
while (packetQueue.Size())
rakPeerInterface->PushBackPacket(packetQueue.Pop(),true);
return false;
}
else if (packet->data[0]==ID_RPC_REMOTE_ERROR && packet->data[1]==RPC_ERROR_FUNCTION_NOT_REGISTERED)
{
RakNet::RakString functionName;
RakNet::BitStream bsIn(packet->data,packet->length,false);
bsIn.IgnoreBytes(2);
bsIn.Read(functionName);
if (functionName==uniqueID)
{
// Push back to head in reverse order
rakPeerInterface->PushBackPacket(packet,true);
while (packetQueue.Size())
rakPeerInterface->PushBackPacket(packetQueue.Pop(),true);
return false;
}
else
{
packetQueue.PushAtHead(packet,0,_FILE_AND_LINE_);
}
}
else
{
packetQueue.PushAtHead(packet,0,_FILE_AND_LINE_);
}
}
}
returnData->Read(blockingReturnValue);
return true;
}