本文整理汇总了C++中std::deque::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::clear方法的具体用法?C++ deque::clear怎么用?C++ deque::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obedientZombie
void AI::obedientZombie(int index, std::deque<int> myOrders)
{
int x, y, humanIndex, wallIndex;
Zombie* me = &zombies[index];
switch (myOrders.front())
{
case 0:
x = nextX(me->x(), me->y(), me->facing());
y = nextY(me->x(), me->y(), me->facing());
humanIndex = getHuman(x, y);
if (humanIndex > -1)
{
myOrders.clear();
me->attack(humans[humanIndex]);
}
else
me->move();
break;
case 1:
me->turn(-1);
break;
case 2:
me->turn(1);
break;
}
if (myOrders.size() > 0)
myOrders.pop_front();
if (myOrders.size() > 0)
orders[me->id()] = myOrders;
else
orders.erase(me->id());
}
示例2: doWork
virtual void doWork()
{
//osg::Timer timer;
//size_t objcount = mObjects.size();
mObjects.clear();
//std::cout << "cleared " << objcount << " objects in " << timer.time_m() << std::endl;
}
示例3: GetEntries
void cHpiSubProviderIdr::GetEntries( std::deque<HpiEntry>& entries ) const
{
entries.clear();
SaErrorT rv;
SaHpiEntryIdT id = SAHPI_FIRST_ENTRY, next_id;
bool first = true;
while( id != SAHPI_LAST_ENTRY ) {
SaHpiIdrAreaHeaderT ahdr;
rv = saHpiIdrAreaHeaderGet( m_ctx.session_id,
m_ctx.resource_id,
m_ctx.instrument_id,
SAHPI_IDR_AREATYPE_UNSPECIFIED,
id,
&next_id,
&ahdr );
if ( first && ( rv == SA_ERR_HPI_NOT_PRESENT ) ) {
break;
}
if ( rv != SA_OK ) {
return;
}
std::wstring name;
MakeNameForIdrArea( ahdr, name );
entries.push_back( HpiEntry( eHpiEntryIdrArea, ahdr.AreaId, name ) );
first = false;
id = next_id;
}
}
示例4: main
int main() {
FILE*fp=stdin;
if (dbg) {
fp = fopen ("in-624.txt", "r");
}
while (fscanf(fp,"%d%d", &limit, &nSongs)==2) {
tracks.clear();
for (int i=0; i<nSongs; i++) {
int trk;
fscanf(fp, "%d", &trk);
tracks.push_back(trk);
}
maxLength=0;
maxq.clear();
// now search max
deque<int> choice;
for (int i=0; i<nSongs; i++)
dfs (choice, i, 0);
for (int i=0; i<maxq.size(); i++)
printf ("%d ", maxq[i]);
printf("sum:%d\n", maxLength);
}
return 0;
}
示例5: handle_pending_requests
void partition_resolver_simple::handle_pending_requests(std::deque<request_context_ptr>& reqs, error_code err)
{
for (auto& req : reqs)
{
if (err == ERR_OK)
{
rpc_address addr;
err = get_address(req->partition_index, addr);
if (err == ERR_OK)
{
end_request(std::move(req), err, addr);
}
else
{
call(std::move(req), true);
}
}
else if (err == ERR_HANDLER_NOT_FOUND)
{
end_request(std::move(req), err, rpc_address());
}
else
{
call(std::move(req), true);
}
}
reqs.clear();
}
示例6: do_stop
void do_stop (CompletionCounter)
{
m_journal.debug << "Stopped";
m_stopped = true;
m_work.clear ();
m_resolver.cancel ();
removeReference ();
}
示例7: clear
void TriggerScriptParam::clear()
{
m_isEnter.clear();
m_names.clear();
m_sources.clear();
m_targets.clear();
m_sourcesCount.clear();
m_targetsCount.clear();
}
示例8: NetworkOnStartGame
/**
** Game will start now.
*/
void NetworkOnStartGame()
{
ThisPlayer->SetName(Parameters::Instance.LocalPlayerName);
for (int i = 0; i < HostsCount; ++i) {
Players[Hosts[i].PlyNr].SetName(Hosts[i].PlyName);
}
DebugPrint("Updates %d, Lag %d, Hosts %d\n" _C_
CNetworkParameter::Instance.gameCyclesPerUpdate _C_
CNetworkParameter::Instance.NetworkLag _C_ HostsCount);
NetworkInSync = true;
CommandsIn.clear();
MsgCommandsIn.clear();
// Prepare first time without syncs.
for (int i = 0; i != 256; ++i) {
for (int p = 0; p != PlayerMax; ++p) {
for (int j = 0; j != MaxNetworkCommands; ++j) {
NetworkIn[i][p][j].Clear();
}
}
}
CNetworkCommandSync nc;
//nc.syncHash = SyncHash;
//nc.syncSeed = SyncRandSeed;
for (unsigned int i = 0; i <= CNetworkParameter::Instance.NetworkLag; i += CNetworkParameter::Instance.gameCyclesPerUpdate) {
for (int n = 0; n < HostsCount; ++n) {
CNetworkCommandQueue(&ncqs)[MaxNetworkCommands] = NetworkIn[i][Hosts[n].PlyNr];
ncqs[0].Time = i;
ncqs[0].Type = MessageSync;
ncqs[0].Data.resize(nc.Size());
nc.Serialize(&ncqs[0].Data[0]);
ncqs[1].Time = i;
ncqs[1].Type = MessageNone;
}
}
memset(NetworkSyncSeeds, 0, sizeof(NetworkSyncSeeds));
memset(NetworkSyncHashs, 0, sizeof(NetworkSyncHashs));
memset(PlayerQuit, 0, sizeof(PlayerQuit));
memset(NetworkLastFrame, 0, sizeof(NetworkLastFrame));
memset(NetworkLastCycle, 0, sizeof(NetworkLastCycle));
}
示例9: GetInfo
void cHpiSubProviderFUMIComponent::GetInfo( std::deque<HpiInfo>& info ) const
{
info.clear();
// TODO bank id == bank num?
Line( info, L"Bank Num", m_ctx.bank_num, UI8_SaHpiBankNum );
GetComponentInfo( info );
GetLogicalComponentInfo( info );
}
示例10: loadNextRegion
bool RegionWellsReader::loadNextRegion(std::deque<int> &wellX, std::deque<int> &wellY, std::deque<std::vector<float> > &wellMeasurements, int &iRegion)
{
wellX.clear();
wellY.clear();
wellMeasurements.clear();
pthread_mutex_lock(read_mutex);
int Y = std::min(nextRegionY*sizeRegionY,(int)wells->NumRows());
int X = std::min(nextRegionX*sizeRegionX,(int)wells->NumCols());
int nY = ((nextRegionY+1)*sizeRegionY);
int nX = ((nextRegionX+1)*sizeRegionX);
wells->SetChunk(Y, std::min(nY-Y,(int)wells->NumRows() - Y),
X, std::min(nX-X,(int)wells->NumCols() - X),
0, wells->NumFlows());
wells->ReadWells();
if (nextRegionX >= numRegionsX) {
pthread_mutex_unlock(read_mutex);
return false; // All regions read already
}
iRegion = nextRegionY + numRegionsY * nextRegionX;
for (int nextY = nextRegionY * sizeRegionY; (nextY < (nextRegionY + 1) * sizeRegionY) && (nextY < sizeY); nextY++) {
for (int nextX = nextRegionX * sizeRegionX; (nextX < (nextRegionX + 1) * sizeRegionX) && (nextX < sizeX); nextX++) {
wellX.push_back(nextX);
wellY.push_back(nextY);
wellMeasurements.push_back(std::vector<float>());
wellMeasurements.back().resize(numFlows);
const WellData *w = wells->ReadXY(nextX, nextY);
copy(w->flowValues, w->flowValues + numFlows, wellMeasurements.back().begin());
}
}
nextRegionY++;
if (nextRegionY == numRegionsY) {
nextRegionY = 0;
nextRegionX++;
}
pthread_mutex_unlock(read_mutex);
return true; // Region reading successful
}
示例11: clearAnimation
void clearAnimation()
{
level = 0;
nCurrentLevel = 1;
nNextLevel = 0;
t = 0.0;
triangles.clear();
vertices.clear();
directions.clear();
} // end function clearCurrentAnimation
示例12: YN_Init
void YN_Init()
{
static int IsInit = 0;
if (IsInit == 0)
{
s_UserLoginInfoQueue.clear();
IsInit = 1;
s_s32LoginID = 0;
}
}
示例13: checkPattern
bool MLPClass::checkPattern(std::deque<double> inPattern, double &mlpVal, double threshold)
{
USES_CONVERSION;
char msgBuf[MAX_PATH];
std::string msgStr;
if(m_openCV_MLP==NULL)
{
return -1.0;
}
float _testSample[MLP_NO_OF_INPUT_LAYERS];
CvMat testSample_mat = cvMat(1, MLP_NO_OF_INPUT_LAYERS, CV_32FC1, _testSample);
float _classificationResult[MLP_NO_OF_OUTPUT_LAYERS];
CvMat classificationResult_mat = cvMat(1, MLP_NO_OF_OUTPUT_LAYERS, CV_32FC1, _classificationResult);
if(inPattern.size()!=MLP_NO_OF_INPUT_LAYERS)
{
inPattern.clear();
return -1;
}
for(int i=0; i<MLP_NO_OF_INPUT_LAYERS; i++)
{
testSample_mat.data.fl[i] = inPattern[i];
}
inPattern.clear();
m_openCV_MLP->predict(&testSample_mat, &classificationResult_mat); // run neural network prediction
mlpVal = classificationResult_mat.data.fl[0];
if(mlpVal>=threshold)
{
return true;
}
else
{
return false;
}
}
示例14: do_stop
//-------------------------------------------------------------------------
// Resolver
void do_stop (CompletionCounter)
{
assert (m_stop_called == true);
if (m_stopped.exchange (true) == false)
{
m_work.clear ();
m_resolver.cancel ();
removeReference ();
}
}
示例15: addAndSetTime
// ------------------------------------------------------------------------
void addAndSetTime(uint32_t ping, uint64_t server_time)
{
if (m_synchronised.load() == true)
return;
if (m_force_set_timer.load() == true)
{
m_force_set_timer.store(false);
m_synchronised.store(true);
STKHost::get()->setNetworkTimer(server_time + (uint64_t)(ping / 2));
return;
}
const uint64_t cur_time = StkTime::getMonoTimeMs();
// Discard too close time compared to last ping
// (due to resend when packet loss)
// 10 packets per second as seen in STKHost
const uint64_t frequency = (uint64_t)((1.0f / 10.0f) * 1000.0f) / 2;
if (!m_times.empty() &&
cur_time - std::get<2>(m_times.back()) < frequency)
return;
// Take max 20 averaged samples from m_times, the next addAndGetTime
// is used to determine that server_time if it's correct, if not
// clear half in m_times until it's correct
if (m_times.size() >= 20)
{
uint64_t sum = std::accumulate(m_times.begin(), m_times.end(),
(uint64_t)0, [cur_time](const uint64_t previous,
const std::tuple<uint32_t, uint64_t, uint64_t>& b)->uint64_t
{
return previous + (uint64_t)(std::get<0>(b) / 2) +
std::get<1>(b) + cur_time - std::get<2>(b);
});
const int64_t averaged_time = sum / 20;
const int64_t server_time_now = server_time + (uint64_t)(ping / 2);
int difference = (int)std::abs(averaged_time - server_time_now);
if (std::abs(averaged_time - server_time_now) <
UserConfigParams::m_timer_sync_difference_tolerance)
{
STKHost::get()->setNetworkTimer(averaged_time);
m_times.clear();
m_force_set_timer.store(false);
m_synchronised.store(true);
Log::info("NetworkTimerSynchronizer", "Network "
"timer synchronized, difference: %dms", difference);
return;
}
m_times.erase(m_times.begin(), m_times.begin() + 10);
}
m_times.emplace_back(ping, server_time, cur_time);
}