本文整理汇总了C++中std::stack::top方法的典型用法代码示例。如果您正苦于以下问题:C++ stack::top方法的具体用法?C++ stack::top怎么用?C++ stack::top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::stack
的用法示例。
在下文中一共展示了stack::top方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例2: build_ListCallback
void build_ListCallback(RDIR *rdir, EListCallbackArg arg)
{
const char *fname = retro_dirent_get_name(rdir);
if(arg == EListCallbackArg_Pop)
{
currPath = pathStack.top();
pathStack.pop();
currVirtPath = virtPathStack.top();
virtPathStack.pop();
return;
}
if (retro_dirent_is_dir(rdir))
{
if(!strcmp(fname,".")) return;
if(!strcmp(fname,"..")) return;
pathStack.push(currPath);
virtPathStack.push(currVirtPath);
currVirtPath = currVirtPath + "/" + fname;
bool ok = LIBFAT::MkDir(currVirtPath.c_str());
if(!ok)
printf("ERROR adding dir %s via libfat\n",currVirtPath.c_str());
currPath = currPath + path_default_slash() + fname;
return;
}
else
{
std::string path = currPath + path_default_slash() + fname;
FILE* inf = fopen(path.c_str(),"rb");
if(inf)
{
u8 * buf;
size_t elements_read;
long len;
fseek(inf, 0, SEEK_END);
len = ftell(inf);
fseek(inf, 0, SEEK_SET);
buf = new u8[len];
elements_read = fread(buf, 1, len, inf);
if (elements_read != len)
printf(
"libfat: %lu bytes read instead of %l.\n",
elements_read,
len
);
fclose(inf);
std::string path = currVirtPath + "/" + fname;
printf("FAT + (%10.2f KB) %s \n",len/1024.f,path.c_str());
bool ok = LIBFAT::WriteFile(path.c_str(),buf,len);
if(!ok)
printf("ERROR adding file to fat\n");
delete[] buf;
} else printf("ERROR opening file for fat\n");
}
}
示例3: OnCommand
//-----------------------------------------------------------------------------
// WM_COMMAND メッセージ処理
//-----------------------------------------------------------------------------
LRESULT OnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
WORD wNotifyCode = HIWORD(wParam);
WORD wID = LOWORD(wParam);
HWND hwndCtl = (HWND)lParam;
int fixed = 0;
switch (wID) {
case ID__1:
fixed = 1;
break;
case ID__2:
fixed = 2;
break;
case ID__3:
fixed = 3;
break;
case ID__4:
fixed = 4;
break;
case ID__5:
fixed = 5;
break;
case ID__6:
fixed = 6;
break;
case ID__7:
fixed = 7;
break;
case ID__8:
fixed = 8;
break;
case ID__9:
fixed = 9;
break;
case ID__0:
fixed = 0;
break;
case IDM_GAME_INIT:
return OnGameInit(hwnd, wParam, lParam);
case IDM_GAME_OPEN:
return OnGameOpen(hwnd, wParam, lParam);
case ID_GAME_PARSE:
if (g_game.Reparse() == 0) {
MessageBox(hwnd, _T("手詰まりです"), _T("数独サポート"), MB_OK);
}
InvalidateRect(hwnd, NULL, FALSE);
return 0;
case ID_GAME_PARSE_ALL:
g_game.ReparseAll();
InvalidateRect(hwnd, NULL, FALSE);
if (g_game.IsFinished()) {
MessageBox(hwnd, _T("解けました"), _T("数独サポート"), MB_OK);
} else {
MessageBox(hwnd, _T("手詰まりです"), _T("数独サポート"), MB_OK);
}
return 0;
case ID_GAME_TOTAL:
if (SoAtari(hwnd)) {
InvalidateRect(hwnd, NULL, FALSE);
MessageBox(hwnd, _T("解けました"), _T("数独サポート"), MB_OK);
} else {
MessageBox(hwnd, _T("やっぱり手詰まりです"), _T("数独サポート"), MB_OK);
}
return 0;
case IDM_GAME_EXIT:
DestroyWindow(hwnd);
return 0;
case ID_HELP_ABOUT:
DialogBox(GetWindowInstance(hwnd), MAKEINTRESOURCE(IDD_ABOUT), hwnd, About_DlgProc);
return 0;
}
if (fixed != 0) {
g_gameStack.push(g_game);
g_game.FixCell(g_yCell, g_xCell, fixed);
g_game.ReparseStart();
} else {
g_game = g_gameStack.top();
g_gameStack.pop();
g_game.ReparseStart();
}
if (g_game.IsFinished()) {
MessageBox(hwnd, _T("解けました"), _T("数独サポート"), MB_OK);
}
InvalidateRect(hwnd, NULL, FALSE);
return 0;
//.........这里部分代码省略.........
示例4: visit
void visit(const CallStmt *op) {
simit_iassert(functionStack.size() > 0);
addReverseEdge(functionStack.top(), op->callee);
op->callee.accept(this);
}
示例5: IsTopDialog
/**
* Check whether the specified dialog is the top-most one.
*/
bool IsTopDialog(WndForm &dialog) {
assert(HasDialog());
return &dialog == dialogs.top();
}
示例6: TransformPop
void TransformPop() { m_mtx=m_transformStack.top(); m_transformStack.pop(); }
示例7: endElement
void endElement(void *ctx, const char *name)
{
CC_UNUSED_PARAM(ctx);
SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top();
const std::string sName((char*)name);
if( sName == "dict" )
{
_stateStack.pop();
_dictStack.pop();
if ( !_dictStack.empty())
{
_curDict = _dictStack.top();
}
}
else if (sName == "array")
{
_stateStack.pop();
_arrayStack.pop();
if (! _arrayStack.empty())
{
_curArray = _arrayStack.top();
}
}
else if (sName == "true")
{
if (SAX_ARRAY == curState)
{
_curArray->push_back(Value(true));
}
else if (SAX_DICT == curState)
{
(*_curDict)[_curKey] = Value(true);
}
}
else if (sName == "false")
{
if (SAX_ARRAY == curState)
{
_curArray->push_back(Value(false));
}
else if (SAX_DICT == curState)
{
(*_curDict)[_curKey] = Value(false);
}
}
else if (sName == "string" || sName == "integer" || sName == "real")
{
if (SAX_ARRAY == curState)
{
if (sName == "string")
_curArray->push_back(Value(_curValue));
else if (sName == "integer")
_curArray->push_back(Value(atoi(_curValue.c_str())));
else
_curArray->push_back(Value(utils::atof(_curValue.c_str())));
}
else if (SAX_DICT == curState)
{
if (sName == "string")
(*_curDict)[_curKey] = Value(_curValue);
else if (sName == "integer")
(*_curDict)[_curKey] = Value(atoi(_curValue.c_str()));
else
(*_curDict)[_curKey] = Value(utils::atof(_curValue.c_str()));
}
_curValue.clear();
}
_state = SAX_NONE;
}
示例8: assert
inline std::deque<Token>& ParserContext::OutputQueue() const
{
assert(!m_OutputQueues.empty());
return *m_OutputQueues.top();
}
示例9: ProcessNoiseObjectPixel
//.........这里部分代码省略.........
return true;
}
else if (s_CheckedPixels[pixel] == WENT_UP)
{
nextPixel = y * width + (x - 1);
s_CheckedPixels[pixel] = WENT_LEFT;
if (x > 0)
{
if (s_CheckedPixels[nextPixel] == UNCHECKED)
{
if (pixels[nextPixel] == onColour)
{
s_ObjectPixelsPath.push(nextPixel);
*pixelRef = nextPixel;
s_ObjectPixelsIndex[s_ObjectPixelsCount] = nextPixel;
s_ObjectPixelsCount++;
SetObjectPixelsXFromTo(nextPixel);
}
else
s_CheckedPixels[nextPixel] = CHECKED;
}
}
return true;
}
else if (s_CheckedPixels[pixel] == WENT_LEFT)
{
nextPixel = y * width + (x + 1);
s_CheckedPixels[pixel] = WENT_RIGHT;
if (x < width - 1)
{
if (s_CheckedPixels[nextPixel] == UNCHECKED)
{
if (pixels[nextPixel] == onColour)
{
s_ObjectPixelsPath.push(nextPixel);
*pixelRef = nextPixel;
s_ObjectPixelsIndex[s_ObjectPixelsCount] = nextPixel;
s_ObjectPixelsCount++;
SetObjectPixelsXFromTo(nextPixel);
}
else
s_CheckedPixels[nextPixel] = CHECKED;
}
}
return true;
}
else if (s_CheckedPixels[pixel] == WENT_RIGHT)
{
nextPixel = (y + 1) * width + x;
s_CheckedPixels[pixel] = WENT_DOWN;
if (y < s_ChunkDenoiseHeight - 1)
{
if (s_CheckedPixels[nextPixel] == UNCHECKED)
{
if (pixels[nextPixel] == onColour)
{
s_ObjectPixelsPath.push(nextPixel);
*pixelRef = nextPixel;
s_ObjectPixelsIndex[s_ObjectPixelsCount] = nextPixel;
s_ObjectPixelsCount++;
SetObjectPixelsXFromTo(nextPixel);
}
else
s_CheckedPixels[nextPixel] = CHECKED;
}
}
return true;
}
else if (s_CheckedPixels[pixel] >= WENT_DOWN)
{
if (s_ObjectPixelsPath.empty())
return false;
s_CheckedPixels[pixel] = CHECKED;
nextPixel = s_ObjectPixelsPath.top();
s_ObjectPixelsPath.pop();
if (pixel == nextPixel && !s_ObjectPixelsPath.empty())
{
nextPixel = s_ObjectPixelsPath.top();
s_ObjectPixelsPath.pop();
}
*pixelRef = nextPixel;
return true;
}
else
return false;
}
示例10: pop
/** \brief
Return a reference to the next element that will be returned by pop().
Does not remove the element.
\pre \c !empty().
*/
Element & head() { return data_.top(); }
示例11: previousGameMode
GameMode::Type previousGameMode() const { return gameModeStack_.top(); }
示例12: Clear
void StateManager::Clear()
{
while(!states.empty())
{ delete states.top(); states.pop(); }
}
示例13: tic
inline void tic() {
stack.push(t0);
gettimeofday(&(stack.top()),NULL);
}
示例14: startElement
void startElement(void *ctx, const char *name, const char **atts)
{
CC_UNUSED_PARAM(ctx);
CC_UNUSED_PARAM(atts);
std::string sName((char*)name);
if( sName == "dict" )
{
m_pCurDict = new CCDictionary<std::string, CCObject*>();
if(! m_pRootDict)
{
// Because it will call m_pCurDict->release() later, so retain here.
m_pRootDict = m_pCurDict;
m_pRootDict->retain();
}
m_tState = SAX_DICT;
CCSAXState preState = SAX_NONE;
if (! m_tStateStack.empty())
{
preState = m_tStateStack.top();
}
if (SAX_ARRAY == preState)
{
// add the dictionary into the array
m_pArray->addObject(m_pCurDict);
}
else if (SAX_DICT == preState)
{
// add the dictionary into the pre dictionary
CCAssert(! m_tDictStack.empty(), "The state is wrong!");
CCDictionary<std::string, CCObject*>* pPreDict = m_tDictStack.top();
pPreDict->setObject(m_pCurDict, m_sCurKey);
}
m_pCurDict->release();
// record the dict state
m_tStateStack.push(m_tState);
m_tDictStack.push(m_pCurDict);
}
else if(sName == "key")
{
m_tState = SAX_KEY;
}
else if(sName == "integer")
{
m_tState = SAX_INT;
}
else if(sName == "real")
{
m_tState = SAX_REAL;
}
else if(sName == "string")
{
m_tState = SAX_STRING;
}
else if (sName == "array")
{
m_tState = SAX_ARRAY;
m_pArray = new CCMutableArray<CCObject*>();
CCSAXState preState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
if (preState == SAX_DICT)
{
m_pCurDict->setObject(m_pArray, m_sCurKey);
}
else if (preState == SAX_ARRAY)
{
CCAssert(! m_tArrayStack.empty(), "The state is worng!");
CCMutableArray<CCObject*>* pPreArray = m_tArrayStack.top();
pPreArray->addObject(m_pArray);
}
m_pArray->release();
// record the array state
m_tStateStack.push(m_tState);
m_tArrayStack.push(m_pArray);
}
else
{
m_tState = SAX_NONE;
}
}
示例15: call_terms
void STACK_ARGS call_terms (void)
{
while (!TermFuncs.empty())
TermFuncs.top().first(), TermFuncs.pop();
}