当前位置: 首页>>代码示例>>C++>>正文


C++ stack::top方法代码示例

本文整理汇总了C++中std::stack::top方法的典型用法代码示例。如果您正苦于以下问题:C++ stack::top方法的具体用法?C++ stack::top怎么用?C++ stack::top使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::stack的用法示例。


在下文中一共展示了stack::top方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getMin

 int getMin() {
     return min.top();
 }
开发者ID:rishdas,项目名称:algo,代码行数:3,代码来源:min_stack.cpp

示例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");
	}
}
开发者ID:lcsaintlee,项目名称:desmume-1,代码行数:63,代码来源:vfat.cpp

示例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;
//.........这里部分代码省略.........
开发者ID:willmomo,项目名称:ry2kojima,代码行数:101,代码来源:SuDoku.cpp

示例4: visit

 void visit(const CallStmt *op) {
   simit_iassert(functionStack.size() > 0);
   addReverseEdge(functionStack.top(), op->callee);
   op->callee.accept(this);
 }
开发者ID:simit-lang,项目名称:simit,代码行数:5,代码来源:ir_queries.cpp

示例5: IsTopDialog

  /**
   * Check whether the specified dialog is the top-most one.
   */
  bool IsTopDialog(WndForm &dialog) {
    assert(HasDialog());

    return &dialog == dialogs.top();
  }
开发者ID:davidswelt,项目名称:XCSoar,代码行数:8,代码来源:SingleWindow.hpp

示例6: TransformPop

 void TransformPop() { m_mtx=m_transformStack.top(); m_transformStack.pop(); }
开发者ID:dehilsterlexis,项目名称:eclide-1,代码行数:1,代码来源:AggMemoryDC.cpp

示例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;
    }
开发者ID:rainswan,项目名称:Quick-Cocos2dx-Community,代码行数:71,代码来源:CCFileUtils.cpp

示例8: assert

inline std::deque<Token>& ParserContext::OutputQueue() const
{
    assert(!m_OutputQueues.empty());
    return *m_OutputQueues.top();
}
开发者ID:UsYer,项目名称:Parserwriting-test,代码行数:5,代码来源:Parser.hpp

示例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;	
}
开发者ID:hpavlov,项目名称:occurec,代码行数:101,代码来源:LargeChunkDenoiser.cpp

示例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(); }
开发者ID:guker,项目名称:flipsta,代码行数:8,代码来源:queue.hpp

示例11: previousGameMode

		GameMode::Type previousGameMode() const { return gameModeStack_.top(); }
开发者ID:take-cheeze,项目名称:rpgtukuru-iphone,代码行数:1,代码来源:Main.hpp

示例12: Clear

void StateManager::Clear()
{
	while(!states.empty())
	{ delete states.top(); states.pop(); }
}
开发者ID:vsrz,项目名称:VHH,代码行数:5,代码来源:StateManager.cpp

示例13: tic

 inline void tic() {
   stack.push(t0);
   gettimeofday(&(stack.top()),NULL);
 }
开发者ID:GaloMALDONADO,项目名称:pinocchio,代码行数:4,代码来源:timer.hpp

示例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;
        }
    }
开发者ID:Basingse,项目名称:cocos2d-x,代码行数:83,代码来源:CCFileUtils.cpp

示例15: call_terms

void STACK_ARGS call_terms (void)
{
	while (!TermFuncs.empty())
		TermFuncs.top().first(), TermFuncs.pop();
}
开发者ID:darkranger-red,项目名称:odamex-maemo5,代码行数:5,代码来源:i_main.cpp


注:本文中的std::stack::top方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。