本文整理汇总了C++中std::list::front方法的典型用法代码示例。如果您正苦于以下问题:C++ list::front方法的具体用法?C++ list::front怎么用?C++ list::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::front方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_buffer_list
void hpc_logger::write_buffer_list(std::list<buffer_info>& llist)
{
while (!llist.empty())
{
buffer_info new_buffer_info = llist.front();
llist.pop_front();
if (_current_log_file_bytes + new_buffer_info.buffer_size >= MAX_FILE_SIZE)
{
_current_log->close();
delete _current_log;
_current_log = nullptr;
create_log_file();
}
_current_log->write(new_buffer_info.buffer, new_buffer_info.buffer_size);
_current_log_file_bytes += new_buffer_info.buffer_size;
free(new_buffer_info.buffer);
}
}
示例2: __RunOnePendingInterrupt
// Returns true if anything was executed.
bool __RunOnePendingInterrupt()
{
if (inInterrupt || !interruptsEnabled)
{
// Already in an interrupt! We'll keep going when it's done.
return false;
}
// Can easily prioritize between different kinds of interrupts if necessary.
retry:
if (pendingInterrupts.size())
{
// If we came from CoreTiming::Advance(), we might've come from a waiting thread's callback.
// To avoid "injecting" return values into our saved state, we context switch here.
__KernelSwitchOffThread("interrupt");
PendingInterrupt pend = pendingInterrupts.front();
SubIntrHandler *handler = intrHandlers[pend.intr].get(pend.subintr);
if (handler == NULL)
{
WARN_LOG(HLE, "Ignoring interrupt, already been released.");
pendingInterrupts.pop_front();
goto retry;
}
intState.save();
handler->copyArgsToCPU(pend);
currentMIPS->r[MIPS_REG_RA] = __KernelInterruptReturnAddress();
inInterrupt = true;
return true;
}
else
{
// DEBUG_LOG(HLE, "No more interrupts!");
return false;
}
}
示例3: GetConnect
void* GetConnect()
{
void* con;
EnterCriticalSection(&secLock);
if(connLists.size()>0)//连接池容器中还有连接
{
con=connLists.front();//得到第一个连接
connLists.pop_front();//移除第一个连接
if(YTConn_GetStatus(con) < 0)//如果连接已经被关闭,删除后重新建立一个
{
YTConn_Close(con);
YTConn_Connect(con);
}
LeaveCriticalSection(&secLock);
return con;
}
else
{
if(iCurConnects< imaxConnects)
{//还可以创建新的连接
con= YTConn_NewConn(ptrConfig);
if (YTConn_Connect(con) < 0)
{
YTConn_DelConn(con);
con = NULL;
}
LeaveCriticalSection(&secLock);
return con;
}
else
{//建立的连接数已经达到maxSize
LeaveCriticalSection(&secLock);
return NULL;
}
}
}
示例4: movePopulation
/**
* @brief Move half the population from the first Cell to the last Cell of cellPath
* @details It should be noted that movePopulation() check wether it's legal to do that move before
*
* @param cellPath a list of pointer to Hexacell, all HexaCell should be adjacent
* @param playerID the Id of the player trying to do that move
*/
void MainWindow::movePopulation(std::list<HexaCell*> cellPath, int playerID )
{
HexaCell* startCell = cellPath.front();
HexaCell* endCell = cellPath.back();
int popToMove = (startCell)->getPopulation() / 2;
if (playerID != startCell->getPlayerID()){
return;
}
if (endCell->getPlayerID() == playerID)
{
startCell->decPopulation(popToMove);
endCell->incPopulation(popToMove);
}
else{
if (endCell->getPopulation() > popToMove){
startCell->decPopulation(popToMove);
endCell->decPopulation(popToMove);
}
else{
startCell->decPopulation(popToMove);
endCell->setPopulation(popToMove - endCell->getPopulation());
if (endCell->getPlayerID() == 1)
hexaCellBoard->removePlayerCell(endCell);
else if (endCell->getPlayerID() == 2)
hexaCellBoard->removeBotCell(endCell);
if (playerID == 1)
hexaCellBoard->addPlayerCell(endCell);
if (playerID == 2)
hexaCellBoard->addBotCell(endCell);
endCell->setPlayerID(playerID);
}
}
startCell->update();
endCell->update();
}
示例5: AddNodeStmt
virtual void AddNodeStmt(Node* n, const AstNodePtr& s)
{
PtrAnal::StmtRef s_stmts = m.translate_stmt(s);
if (s_stmts.size() == 0) {
if (fa.IsStatement(s))
return;
PtrAnal::Stmt s_exp = m.translate_exp(s).stmt;
assert(s_exp != 0);
s_stmts.push_back(s_exp);
}
if (n->size()) {
m.contrl_flow(n->back(), s_stmts.front(), CFGConfig::ALWAYS);
}
else if (n == &nodes.front())
m.contrl_flow(defn, s_stmts.front(), CFGConfig::ALWAYS);
PtrAnal::StmtRef::const_iterator p = s_stmts.begin();
n->push_back(*p);
for (++p; p != s_stmts.end(); ++p) {
PtrAnal::Stmt cur = *p;
m.contrl_flow(n->back(), cur, CFGConfig::ALWAYS);
n->push_back(cur);
}
std::map<Node*, EdgeInfo>::iterator p_pending = pending_in.find(n);
if (p_pending != pending_in.end()) {
EdgeInfo& cur = (*p_pending).second;
for (std::list<std::pair<Node*,EdgeType> >::const_iterator
p_edge=cur.begin(); p_edge != cur.end(); ++p_edge) {
Node* n1 = (*p_edge).first;
if (n1->size())
m.contrl_flow( n1->back(), n->front(), (*p_edge).second);
else
pending_out[n1].push_back(std::pair<Node*,EdgeType>(n, (*p_edge).second));
}
pending_in.erase(p_pending);
}
}
示例6: MassQueue
void CLogRequest::MassQueue(std::list<std::string>& queue )
{
while (!queue.empty())
{
std::string event = queue.front();
queue.pop_front();
if(mData.size() == 0)
{
mData = event;
}
else
{
mData += "~" + event;
if ( mData.length() > 300)
{
Send();
CLogRequest newRequest(mTrackUrl);
newRequest.MassQueue(queue);
return;
}
}
}
Send();
}
示例7: test_with_empty_headers
void test_with_empty_headers()
{
multipartparser parser;
#define BOUNDARY "boundary"
#define BODY \
"--" BOUNDARY "\r\n" \
"\r\n" \
"This is implicitly typed plain ASCII text.\r\n" \
"It does NOT end with a linebreak." \
"\r\n--" BOUNDARY "--\r\n"
init_globals();
multipartparser_init(&parser, BOUNDARY);
assert(multipartparser_execute(&parser, &g_callbacks, BODY, strlen(BODY)) == strlen(BODY));
assert(g_body_begin_called);
assert(g_parts.size() == 1);
assert(g_parts.front().headers.empty());
assert(g_body_end_called);
#undef BOUNDARY
#undef BODY
}
示例8: AlarmHandler
// SIGINT alarm handler: alarm set by entity handler. Does
// slow response when fired
void AlarmHandler(int sig)
{
if (sig == SIGALRM)
{
OC_LOG (INFO, TAG, "Server starting slow response");
if (gRequestList.empty())
{
OC_LOG (INFO, TAG, "No requests to service");
return;
}
// Get the request from the list
OCEntityHandlerRequest *entityHandlerRequest = gRequestList.front();
gRequestList.pop_front();
if (entityHandlerRequest->method == OC_REST_GET)
{
OC_LOG (INFO, TAG, "Received OC_REST_GET from client");
ProcessGetRequest (entityHandlerRequest);
}
else
{
OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
entityHandlerRequest->method);
}
// Free the request
OCFree(entityHandlerRequest->query);
OCFree(entityHandlerRequest->reqJSONPayload);
OCFree(entityHandlerRequest);
// If there are more requests in list, re-arm the alarm signal
if (gRequestList.empty())
{
alarm(SLOW_RESPONSE_DELAY_SEC);
}
}
}
示例9: roll
void _MaxSizeLogAppender::roll()
{
std::stringstream newPath_stream;
newPath_stream << context.path << "." << getCurrDateTime();
std::stringstream postfix_stream;
postfix_stream << "(" << currBackupCount++ << ")";
std::string newPath = rename(newPath_stream.str().c_str(),
postfix_stream.str().c_str());
backupList.push_back(newPath);
if (backupList.size() > (size_t) maxBackupCount)
{
std::string remove_path = backupList.front();
backupList.pop_front();
int e = remove(remove_path.c_str());
if (e != 0)
{
perror("remove");
}
}
}
示例10: fl
char *send_command(zmq::socket_t &sock, std::list<Value> ¶ms) {
if (params.size() == 0) return 0;
Value cmd_val = params.front();
params.pop_front();
std::string cmd = cmd_val.asString();
char *msg = MessageEncoding::encodeCommand(cmd, ¶ms);
{FileLogger fl(program_name); fl.f() << "sending: " << msg << "\n"; }
if (options.verbose) std::cout << " sending: " << msg << "\n";
sendMessage(sock, msg);
size_t size = strlen(msg);
free(msg);
{FileLogger fl(program_name); fl.f() << "getting reply:\n"; }
zmq::message_t reply;
if (sock.recv(&reply)) {
{FileLogger fl(program_name); fl.f() << "got reply:\n"; }
size = reply.size();
char *data = (char *)malloc(size+1);
memcpy(data, reply.data(), size);
data[size] = 0;
return data;
}
return 0;
}
示例11: write_cb
/* Socket dapat ditulis */
void write_cb(ev::io &watcher) {
if (write_queue.empty()) {
io.set(ev::READ);
return;
}
Buffer* buffer = write_queue.front();
ssize_t written = write(watcher.fd, buffer->dpos(), buffer->nbytes());
if (written < 0) {
perror("read error");
return;
}
buffer->pos += written;
if (buffer->nbytes() == 0) {
write_queue.pop_front();
delete buffer;
}
/* Tutup dan bebaskan watcher saat selesai mengirim response (stateless) */
io.stop();
close(sfd);
}
示例12: performFilling
void performFilling() {
Range *range = generateRangeAndReplaceColor(start_point.y, start_point.x, UP);
ranges.push_back(range);
ranges.push_back(new Range(range->line, range->start, range->end, DOWN));
int row;
while (!ranges.empty()) {
range = ranges.front();
if (range->direction == UP) {
row = range->line - 1;
if (row >= 0) {
checkRangeAndGenerateNewRanges(range, row, UP);
}
} else {
row = range->line + 1;
if (row < y_size) {
checkRangeAndGenerateNewRanges(range, row, DOWN);
}
}
ranges.pop_front();
delete(range);
}
}
示例13: getWrstBattPship
void matchRecord::getWrstBattPship(std::list<playerInnsRecord> &b1,
std::list<playerInnsRecord> &b2 ) const
{
for (int i = 0; i < nPlayersPerTeam ; i += 2)
{
// test whether this batting pship is worse than the worst seen so far
if ( battingRec[i].runsScored + battingRec[i + 1].runsScored
< b1.front().runsScored + b2.front().runsScored )
{
// remove all but one record from both lists
while (b1.size() > 1) b1.pop_back();
while (b2.size() > 1) b2.pop_back();
// update remaining records
b1.front() = playerInnsRecord(battingRec[i].runsScored,
battingRec[i].batsmansName,
teamName, date );
b2.front() = playerInnsRecord(battingRec[i + 1].runsScored,
battingRec[i + 1].batsmansName,
teamName, date );
}
else
// test whether this batting pship is equal to the worst seen so far
if ( battingRec[i].runsScored + battingRec[i + 1].runsScored
== b1.front().runsScored + b2.front().runsScored )
{
// add record to list
b1.push_back(playerInnsRecord(battingRec[i].runsScored,
battingRec[i].batsmansName,
teamName, date ));
b2.push_back(playerInnsRecord(battingRec[i + 1].runsScored,
battingRec[i + 1].batsmansName,
teamName, date ));
}
}
}
示例14: proceed
/** \copydoc Option::proceed */
void proceed (const std::list<std::string>& args, IProperties& props)
{
props.add (0, getName(), args.front());
}
示例15:
CHECK_TEST_CONDITION(r);
CHECK_EQ(2, c.get_alternative_blocks_count());
// Some blocks that were in main chain are in alt chain now
BOOST_FOREACH(block b, alt_blocks)
{
CHECK_TEST_CONDITION(m_chain_1.end() != std::find(m_chain_1.begin(), m_chain_1.end(), b));
}
std::vector<cryptonote::block> chain;
map_hash2tx_t mtx;
r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back()));
CHECK_TEST_CONDITION(r);
CHECK_EQ(MK_COINS(8), get_balance(m_recipient_account_1, chain, mtx));
CHECK_EQ(MK_COINS(3), get_balance(m_recipient_account_2, chain, mtx));
CHECK_EQ(MK_COINS(14), get_balance(m_recipient_account_3, chain, mtx));
CHECK_EQ(MK_COINS(16), get_balance(m_recipient_account_4, chain, mtx));
std::list<transaction> tx_pool;
c.get_pool_transactions(tx_pool);
CHECK_EQ(1, tx_pool.size());
CHECK_TEST_CONDITION(!(tx_pool.front() == m_tx_pool.front()));
std::vector<size_t> tx_outs;
uint64_t transfered;
lookup_acc_outs(m_recipient_account_2.get_keys(), tx_pool.front(), tx_outs, transfered);
CHECK_EQ(MK_COINS(7), transfered);
return true;
}