本文整理汇总了C++中Pop函数的典型用法代码示例。如果您正苦于以下问题:C++ Pop函数的具体用法?C++ Pop怎么用?C++ Pop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: popOrSleep
T popOrSleep() {
std::unique_lock<std::mutex> lock(m_mutex);
while(m_container.empty()) m_empty.wait(lock);
T res = Pop(m_container, 0);
return res;
}
示例2: FlushText
void SystemDraw::EndOp()
{
FlushText();
Pop();
}
示例3: CompactaArquivo
void CompactaArquivo(ARVORE *Raiz)
{
// Definição de variáveis
FILE *P1, *P2;
DADOS Info;
ARVORE *q, *p;
PILHA PilhaA;
int VLogico, valor = 0;
// Inicialização das variáveis
q = Raiz;
VLogico = 1;
PilhaA.Topo = 0;
P1 = fopen("AGENDA.DAT", "rb");
if (P1 == NULL)
return;
P2 = fopen("NOVO.DAT", "wb+");
if (P2 == NULL)
{
fclose(P1);
return;
}
while (VLogico == 1)
{
// Varrendo a SubArvore a Esquerda
while(q != NULL)
{
p = q;
fseek(P1, p->EnderecoRegistro, 0);
fread(&Info, sizeof(DADOS), 1, P1);
fwrite(&Info, sizeof(DADOS), 1, P2);
p->EnderecoRegistro = valor * sizeof(DADOS);
valor++;
Push(&PilhaA, p);
q = p->LL;
}
q = Pop(&PilhaA);
if ((PilhaA.Topo == 0) && (q->RL == NULL)) VLogico = 0;
q = q->RL;
}
// SalvaArvore(Raiz);
fclose(P1);
fclose(P2);
// Remove o arquivo original, com lixo
if (remove("AGENDA.DAT") != 0) {
printf("\n\tNao foi possivel remover o arquivo AGENDA.DAT.\n");
getch();
return;
}
// Transforma o arquivo Novo.dat, no arquivo original
if (rename("NOVO.DAT", "AGENDA.DAT") != 0) {
printf("\n\tNao foi possivel renomear o arquivo NOVO.DAT.\n");
getch();
return;
}
} // Fim de CompactaArquivo
示例4: Pop
/*!
\param Func
*/
xbShort xbExpn::ProcessFunction( char * Func )
{
/* 1 - pop function from stack
2 - verify function name and get no of parms needed
3 - verify no of parms >= remainder of stack
4 - pop parms off stack
5 - execute function
6 - push result back on stack
*/
char *buf = 0;
xbExpNode *p1, *p2, *p3, *WorkNode, *FuncNode;
xbShort ParmsNeeded,len;
char ptype = 0; /* process type s=string, l=logical, d=double */
xbDouble DoubResult = 0;
xbLong IntResult = 0;
FuncNode = (xbExpNode *) Pop();
ParmsNeeded = GetFuncInfo( Func, 1 );
if( ParmsNeeded == -1 ) {
return XB_INVALID_FUNCTION;
}
else {
ParmsNeeded = 0;
if( FuncNode->Sibling1 ) ParmsNeeded++;
if( FuncNode->Sibling2 ) ParmsNeeded++;
if( FuncNode->Sibling3 ) ParmsNeeded++;
}
if( ParmsNeeded > GetStackDepth())
return XB_INSUFFICIENT_PARMS;
p1 = p2 = p3 = NULL;
if( ParmsNeeded > 2 ) p3 = (xbExpNode *) Pop();
if( ParmsNeeded > 1 ) p2 = (xbExpNode *) Pop();
if( ParmsNeeded > 0 ) p1 = (xbExpNode *) Pop();
memset( WorkBuf, 0x00, WorkBufMaxLen+1);
if( strncmp( Func, "ABS", 3 ) == 0 ) {
ptype = 'd';
DoubResult = ABS( GetDoub( p1 ));
}
else if( strncmp( Func, "ASC", 3 ) == 0 ) {
ptype = 'd';
DoubResult = ASC( p1->StringResult );
}
else if( strncmp( Func, "AT", 2 ) == 0 ) {
ptype = 'd';
DoubResult = AT( p1->StringResult, p2->StringResult );
}
else if( strncmp( Func, "CDOW", 4 ) == 0 ) {
ptype = 's';
buf = CDOW( p1->StringResult );
}
else if( strncmp( Func, "CHR", 3 ) == 0 ) {
ptype = 's';
buf = CHR( GetInt( p1 ));
}
else if( strncmp( Func, "CMONTH", 6 ) == 0 ) {
ptype = 's';
buf = CMONTH( p1->StringResult );
}
else if( strncmp( Func, "CTOD", 4 ) == 0 ) {
ptype = 's';
buf = CTOD( p1->StringResult );
}
else if( strncmp( Func, "DATE", 4 ) == 0 ) {
ptype = 's';
buf = DATE();
}
else if( strncmp( Func, "DAY", 3 ) == 0 ) {
ptype = 'd';
DoubResult = DAY( p1->StringResult );
}
else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'C' ) {
ptype = 's';
buf = DESCEND( p1->StringResult.c_str() );
}
else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'N' ) {
ptype = 'd';
DoubResult = DESCEND( GetDoub( p1 ));
}
else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'D' ) {
xbDate d( p1->StringResult );
ptype = 'd';
DoubResult = DESCEND( d );
}
else if( strncmp( Func, "DOW", 3 ) == 0 ) {
ptype = 'd';
DoubResult = DOW( p1->StringResult );
}
else if( strncmp( Func, "DTOC", 4 ) == 0 ) {
ptype = 's';
buf = DTOC( p1->StringResult );
}
//.........这里部分代码省略.........
示例5: Configurable
Configurable::Configurable(Configurable const &other) : Configurable() {
m_db_->Set(other.m_db_);
Push();Pop();
}
示例6: main
int main(void)
{
int select; /*保存选择变量*/
Elem e; /*保存从函数返回的结点的值*/
Elem v; /*保存传递给函数的结点的值*/
size_t i= 0;
LINKSTACK S;
InitStack(&S); /*初始化栈*/
srand((int)time(NULL));
while (1) /*[email protected]*/
{
if (!(S.pBottom))
{
printf("栈不存在!\n");
break;
}
system("cls");
Menu();
printf("请输入您的选择(1~9):");
scanf("%d", &select);
getchar();
switch (select) /*[email protected]*/
{
case 1: /*入栈.*/
v = InputValue("入栈元素为:");
Push(&S, v);
printf("入栈操作成功!\n");
getchar();
break;
case 2: /*输出栈中元素.*/
printf("栈为:");
TraveStack(&S);
getchar();
break;
case 3: /*出栈.*/
if (OK == Pop(&S, &e))
{
printf("出栈成功,出栈元素是%d!\n", e);
}
else
{
printf("出栈失败!\n");
}
getchar();
break;
case 4: /*输出栈的长度.*/
printf("栈长为: %d \n", StackLength(&S));
getchar();
break;
case 5: /*清空栈.*/
ClearStack(&S);
printf("该栈已经清空!\n");
getchar();
break;
case 6: /*销毁栈.*/
DestroyStack(&S);
printf("栈已删除!\n");
getchar();
break;
case 7: /*返回栈顶结点元素.*/
if (OK == GetTop(&S, &e))
{
printf("栈顶为:%d\n", e);
}
else
{
printf("不存在栈顶元素!\n");
}
getchar();
break;
case 8: /*判断栈是否为空.*/
if (StackEmpty(&S) == TRUE)
{
printf("栈为空!\n");
}
else
{
printf("栈非空!\n");
}
getchar();
break;
//.........这里部分代码省略.........
示例7: __attribute__
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// 073 ASSIGN_MOP(z, SGB)
__attribute__((always_inline)) static inline void E_SG_(CARD16 arg) {
if (DEBUG_TRACE_OPCODE) logger.debug("TRACE %6o SG %3d", savedPC, arg);
CARD16 *p = Store(GF + arg);
// NO PAGE FAULT AFTER HERE
*p = Pop();
}
示例8: ApuAE
void ApuAE()
{
// POP A
Pop(IAPU.YA.B.A);
IAPU.PC++;
}
示例9: switch
void CMathParser::Reduce(WORD Reduction)//{ Completes a reduction }
{
TokenRec Token1, Token2;
switch(Reduction)
{
case 1 :
{
Pop(Token1);
Pop(Token2);
Pop(Token2);
CurrToken.Value = Token1.Value + Token2.Value;
break;
}// end;
case 2 : {//begin
Pop(Token1);
Pop(Token2);
Pop(Token2);
CurrToken.Value = Token2.Value - Token1.Value;
break;
}// end;
case 4 :// begin
{
Pop(Token1);
Pop(Token2);
Pop(Token2);
CurrToken.Value = Token1.Value * Token2.Value;
break;
}// end;
case 5 : //begin
{
Pop(Token1);
Pop(Token2);
Pop(Token2);
if (fabs(Token1.Value) < 0.000001 )
ErrorCode = MP_ErrMath;
else
CurrToken.Value = Token2.Value / Token1.Value;
break;
}// end;
//{ MOD operator }
case 100 : //begin
{
Pop(Token1);
Pop(Token2);
Pop(Token2);
if (fabs(Token1.Value) < 0.000001)
ErrorCode = MP_ErrMath;
else
CurrToken.Value = Round(Token2.Value) % Round(Token1.Value);
break;
}//end;
case 7 :
{
Pop(Token1);
Pop(Token2);
Pop(Token2);
if (Token2.Value < 0.0)
ErrorCode = MP_ErrMath;
else if ((Token1.Value * log(Token2.Value) < -MP_ExpLimit) ||
(Token1.Value * log(Token2.Value) > MP_ExpLimit))
ErrorCode = MP_ErrMath;
else
CurrToken.Value = exp(Token1.Value * log(Token2.Value));
break;
}//end;
case 9 :
{//begin
Pop(Token1);
Pop(Token2);
CurrToken.Value = -Token1.Value;
break;
}//end;
case 11 : break;//raise Exception.Create('Invalid reduction'); break;
case 13 : break;//raise Exception.Create('Invalid reduction'); break;
case 14 :
{//begin
Pop(Token1);
Pop(CurrToken);
Pop(Token1);
break;
}//end;
case 16 :
{//begin
Pop(Token1);
Pop(CurrToken);
Pop(Token1);
Pop(Token1);
if( Token1.FuncName == "ABS")
CurrToken.Value = fabs(CurrToken.Value);
else if (Token1.FuncName == "ATAN")
CurrToken.Value = atan(CurrToken.Value);
else if (Token1.FuncName == "COS")
{// begin
if ((CurrToken.Value < -9E18) || (CurrToken.Value > 9E18))
ErrorCode = MP_ErrMath;
else
//.........这里部分代码省略.........
示例10: escribir
//.........这里部分代码省略.........
if((texto.valuni)==0){
return;
}
}
if(oblichar(fmdisk.type)==0){
strcpy(fmdisk.type,"p");
//printf("TYPE DEFAULT P %s \n",fmdisk.type);
}else{
if(evaluartype(fmdisk.type)==0){
return;}
}
if(oblichar(fmdisk.fit)==0){
strcpy(fmdisk.fit,"wf");
// printf("FIT DEFAULT WF %s \n",fmdisk.fit);
}else{
if(evaluarfit(fmdisk.fit)==0){
return;
}
}
if(oblichar(fmdisk.dele)==0){
}else{
if(evaluardele(fmdisk.dele)==0){
return;
}
}
particiones();
}else if(orden == 4){
printf("%s %s",name,path);
if(oblichar(name)==0 || oblichar(path)==0){
Pop(&pil);
printf("\n PARA MONTAR PARTICION DEBES INGRESAR LOS PARAMENTROS OBLIGATORIOS \n");
return;
}
buscpath();
strcpy(path,sincomas);
scad(name);
strcpy(name,sincomas);
montpart();
}else if(orden == 6){
if(oblichar(exec)==0){
printf("\n ERROR, PARAMETROS OBLIGATORIOS VACIOS \n");
return;
}
buscpath();
strcpy(exec,sincomas);
leerscript(exec);
}
if(orden == 7){
char l = 97;
printf("caracter %c %s\n",l,id);
/*char ide[1];
ide[0] = id[3];
int n;
n = atoi(ide);
*/
if(oblichar(namer)==0 || oblichar(pathr)==0 || oblichar(id)==0){
printf("\n ERROR, PARAMETROS OBLIGATORIOS VACIOS \n");
return;
}
char ide[1];
ide[0] = id[3];
int n;
n = atoi(ide);
printf("%s %d",id,n);
printf("llegue aqui");
if(busPart(&pil, n)==1){
return;
}
buscpath();
strcpy(pathr,sincomas);
carpeta(pathr);
graphviz(pathr);
// return v;
}
orden = 0;
}
示例11: malloc
/*------------------------------------------------------------------
* Function: Search
* Purpose: Search for an optimal tour
* Global vars in: mat, n
* Global vars in/out: best_tour
*/
void *Search(void* rank) {
city_t nbr;
city_t city;
weight_t cost;
weight_t local_best_cost = best_tour.cost;
tour_t* tour_p;
stack_elt_t* stack_p = NULL;
stack_elt_t* temp_p;
long my_rank = (long) rank;
int quotient, leftovers, i;
int partial_tour_count, first_final_city, last_final_city;
quotient = (n-1) / thread_count;
leftovers = (n-1) % thread_count;
if(my_rank < leftovers){
partial_tour_count = quotient+1;
first_final_city = my_rank*partial_tour_count + 1;
}
else{
partial_tour_count = quotient;
first_final_city = my_rank*partial_tour_count + leftovers + 1;
}
last_final_city = first_final_city + partial_tour_count - 1;
for(i = first_final_city; i <= last_final_city; i++){
tour_p = malloc(sizeof(tour_t));
Initialize_tour(tour_p);
tour_p->cities[tour_p->count] = 0;
tour_p->count++;
tour_p->cost = 0;
temp_p = malloc(sizeof(stack_elt_t));
temp_p->tour_p = tour_p;
temp_p->city = i;
temp_p->cost = mat[i];
temp_p->next_p = stack_p;
stack_p = temp_p;
}
while (!Empty(stack_p)) {
Pop(&tour_p, &city, &cost, &stack_p);
tour_p->cities[tour_p->count] = city;
tour_p->cost += cost;
tour_p->count++;
if (tour_p->count == n) {
if (tour_p->cost + mat[city*n + 0] < local_best_cost){
Check_best_tour(city, tour_p, &local_best_cost);
}
} else {
for (nbr = n-1; nbr > 0; nbr--) {
pthread_mutex_lock(&mutex);
if (Feasible(city, nbr, tour_p, local_best_cost))
Push(tour_p, nbr, mat[n*city+nbr], &stack_p);
pthread_mutex_unlock(&mutex);
}
}
/* Push duplicates the tour. So it needs to be freed */
free(tour_p->cities);
free(tour_p);
} /* while */
return NULL;
} /* Search */
示例12: fseek
//.........这里部分代码省略.........
" =", // $11
" =", // $12
"", // $13
" +=", // $14
" =+", // $15
" +/-", // $16
" -/+", // $17
" +-", // $18
" -+", // $19
" +-", // $20
" -+" // $21
}; */
push_back = ch;
state = save_state;
}
else if( ch == '(' && (
state!=HEADER &&
state!=IN_COMMENT &&
state!=ERROR_STATE &&
state!=IN_MOVE_BLACK &&
state!=IN_MOVE_WHITE
)
)
state = Push(state);
else if( ch == ')' && (
state!=HEADER &&
state!=IN_COMMENT &&
state!=ERROR_STATE &&
state!=IN_MOVE_BLACK &&
state!=IN_MOVE_WHITE
)
)
{
state = Pop();
}
else
{
switch( state )
{
case IN_COMMENT:
{
if( len < sizeof(comment_buf)-3 )
{
if( comment_ch == '{' )
comment_buf[len++] = (char)ch;
else
{
if( ch!=';' || previous_ch!='\n' )
comment_buf[len++] = (char)ch;
}
}
break;
}
case INIT:
{
push_back = ch;
state = PREFIX;
break;
}
case PREFIX:
{
if( ch == '[' )
{
示例13: while
bool WaitList::WakeupWaiters(bool status)
{
while (Head() != NULL)
Dispatcher::Call(Pop(), status);
return OK;
}
示例14: assert
void NodeBuilder::OnMapEnd() {
assert(m_mapDepth > 0);
m_mapDepth--;
Pop();
}
示例15: ApuCE
void ApuCE()
{
// POP X
Pop(IAPU.X);
IAPU.PC++;
}