本文整理汇总了C++中stack::top方法的典型用法代码示例。如果您正苦于以下问题:C++ stack::top方法的具体用法?C++ stack::top怎么用?C++ stack::top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stack
的用法示例。
在下文中一共展示了stack::top方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例2: next
int next(){
TreeNode* cur = stk.top();
stk.pop();
push(cur->right);
return cur->val;
}
示例3: get_relation
// get one relation from stack
relation Token::get_relation() {
relation r = relation_set.top();
relation_set.pop();
return r;
}
示例4: rightMultiply
void rightMultiply(const mat4 &M, stack<mat4> &transfstack)
{
mat4 &T = transfstack.top();
T = T * M;
}
示例7: bk
inline void bk(stack<int>& from, stack<int>& to) {
from.push(to.top());
to.pop();
}
示例8: getMin
int getMin() {
return stk_min.top();
}
示例9: stackQuery
void XapianEngine::stackQuery(const QueryProperties &queryProps,
stack<Xapian::Query> &queryStack, const string &stemLanguage, bool followOperators)
{
Xapian::Query::op queryOp = Xapian::Query::OP_OR;
string term;
// Get the terms to AND together
if (queryProps.getAndWords().empty() == false)
{
vector<string> andTerms;
if (extractWords(queryProps.getAndWords(), stemLanguage, andTerms) == true)
{
#ifdef DEBUG
cout << "XapianEngine::stackQuery: OP_AND " << andTerms.size() << endl;
#endif
if (followOperators == true)
{
queryOp = Xapian::Query::OP_AND;
}
queryStack.push(Xapian::Query(queryOp, andTerms.begin(), andTerms.end()));
}
}
// Get the terms of the phrase
if (queryProps.getPhrase().empty() == false)
{
vector<string> phraseTerms;
if (extractWords(queryProps.getPhrase(), stemLanguage, phraseTerms) == true)
{
#ifdef DEBUG
cout << "XapianEngine::stackQuery: OP_PHRASE " << phraseTerms.size() << endl;
#endif
if (followOperators == true)
{
queryOp = Xapian::Query::OP_PHRASE;
}
queryStack.push(Xapian::Query(queryOp, phraseTerms.begin(), phraseTerms.end()));
}
}
// Get the terms to OR together
if (queryProps.getAnyWords().empty() == false)
{
vector<string> orTerms;
if (extractWords(queryProps.getAnyWords(), stemLanguage, orTerms) == true)
{
#ifdef DEBUG
cout << "XapianEngine::stackQuery: OP_OR " << orTerms.size() << endl;
#endif
if (followOperators == true)
{
queryOp = Xapian::Query::OP_OR;
}
queryStack.push(Xapian::Query(queryOp, orTerms.begin(), orTerms.end()));
}
}
// Get the terms to NOT together
if (queryProps.getNotWords().empty() == false)
{
vector<string> notTerms;
if (extractWords(queryProps.getNotWords(), stemLanguage, notTerms) == true)
{
#ifdef DEBUG
cout << "XapianEngine::stackQuery: OP_AND_NOT " << notTerms.size() << endl;
#endif
// We need something to AND_NOT these terms against
// Not following the operator would make us return documents
// that have terms the user isn't interested in
Xapian::Query notQuery(Xapian::Query::OP_AND, notTerms.begin(), notTerms.end());
if (queryStack.empty() == false)
{
Xapian::Query topQuery = queryStack.top();
queryStack.pop();
queryStack.push(Xapian::Query(Xapian::Query::OP_AND_NOT, topQuery, notQuery));
}
}
}
// Get the host name filter
if (queryProps.getHostFilter().empty() == false)
{
vector<string> hostTerms;
term = "H";
term += StringManip::toLowerCase(queryProps.getHostFilter());
hostTerms.push_back(term);
if (followOperators == true)
{
queryOp = Xapian::Query::OP_AND;
}
queryStack.push(Xapian::Query(queryOp, hostTerms.begin(), hostTerms.end()));
}
// Get the file name filter
//.........这里部分代码省略.........
示例10: next
/** @return the next smallest number */
int next() {
TreeNode *cur = myStack.top();
myStack.pop();
pushAll(cur->right);
return cur->val;
}
示例11: getAllStack
void getAllStack(){
while( st.size() != 0 ){
ans.push_back(st.top());
st.pop();
}
}
示例12: rightmultiply
void rightmultiply(const mat4 & M, stack<mat4> &transfstack) {
mat4 &T = transfstack.top() ;
// Right multiply M, but do this left to account for row/column major
T = T*M ;
}
示例13: matransform
// The function below applies the appropriate transform to a 4-vector
void matransform(stack<mat4> &transfstack, GLfloat * values) {
mat4 transform = transfstack.top() ;
vec4 valvec = vec4(values[0],values[1],values[2],values[3]) ;
vec4 newval = valvec * transform ;
for (int i = 0 ; i < 4 ; i++) values[i] = newval[i] ;
}
示例14: peek
// Get the front element.
int peek(void) {
if (stk1.empty())
return stk2.top();
else
return stk1.top();
}
示例15: getTope
//devuelve el primer elemento de "mi_pila"
string getTope(stack<string> mi_pila)
{
return mi_pila.top(); // con el top() nos permite devolver el elemento dentro de la pila
}