这篇教程C++ top函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中top函数的典型用法代码示例。如果您正苦于以下问题:C++ top函数的具体用法?C++ top怎么用?C++ top使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了top函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: in2postchar* in2post(char* equation){ char* copy = strdup(equation); //Initialize a copy of the original equation char** equationArray = (char**)malloc(256*sizeof(char*)); //Initialize an array of strings to hold 256 strings char* p = strtok(copy," "); //Tokenizer to delimit a space int i = 0; //Iterator int arraySize = 0; //Keep track of the size of the array of strings char* postfix = (char*)malloc(128*sizeof(char)); //Initialize a variable to hold the postfix expression with suitable size //Creates an array containing the delimited while(p != NULL) { equationArray[i++] = p; p = strtok(NULL, " "); arraySize++; } char* stack[arraySize]; //Creates a stack with enough size to hold all the postfix operator/operands //Iterate through each operand and operator for infix to postfix conversion for( i = 0; i < arraySize; i++){ //Determine if the element is an operator if(strcmp(equationArray[i], "+") == 0 || strcmp(equationArray[i],"-") == 0 || strcmp(equationArray[i], "*") == 0 || strcmp(equationArray[i], "/") == 0 || strcmp(equationArray[i], "(") == 0 || strcmp(equationArray[i], ")") == 0) { //Push to stack if there are no elements in the stack if(topIndex == -1) { push(equationArray[i], stack); } //If it's plus or minus, it will concatenate the last element of //the stack as long as the priority is the same of higher. else if(strcmp(equationArray[i], "(") == 0) { push(equationArray[i], stack); } else if(strcmp(equationArray[i], ")") == 0) { while(strcmp(top(stack), "(") != 0) { strcat(postfix, pop(stack)); strcat(postfix, " "); } pop(stack); } else if(strcmp(equationArray[i], "+") == 0 || strcmp(equationArray[i], "-") == 0){ while(strcmp(top(stack), "+") == 0 || strcmp(top(stack), "-") ==0 || strcmp(top(stack), "*") == 0 || strcmp(top(stack),"/") == 0 ) { strcat(postfix, pop(stack)); strcat(postfix, " "); } //Pushes most recent operator to stack push(equationArray[i], stack); } //If it's a multiplication or division symbol, it keeps //concatenating the top stack elements as longa s it has the same //precendence. else if(strcmp(equationArray[i], "*") == 0 || strcmp(equationArray[i], "/") == 0) { while(strcmp(top(stack), "*") == 0 || strcmp(top(stack), "/") == 0 ) { strcat(postfix, pop(stack)); strcat(postfix, " "); } //Pushes most recent operator to stack push(equationArray[i], stack); } } //Concatenate to the postfix expression if element is an operand else { strcat(postfix, equationArray[i]); strcat(postfix, " "); } } //Concatenates all the remaining elements in the stack to the final //postfix expression while(topIndex != -1) { strcat(postfix, pop(stack)); strcat(postfix, " "); } //Free memory used to hold copy free(copy); //Return the final postfix expression return postfix;}
开发者ID:tpa27,项目名称:ArithmeticRecognitionSoftware,代码行数:77,
示例2: topvoid MotionMaster::UpdateFinalDistanceToTarget(float fDistance){ if (!empty()) top()->UpdateFinalDistance(fDistance);}
开发者ID:dythzer,项目名称:mangoszero,代码行数:5,
示例3: DefaultScreenconst QRect XfitMan::availableGeometry(int screen) const{ QDesktopWidget *d = QApplication::desktop(); if (screen < 0 || screen >= d->screenCount()) screen = d->primaryScreen(); QRect available = d->screenGeometry(screen); // Iterate over all the client windows and subtract from the available // area the space they reserved on the edges (struts). // Note: _NET_WORKAREA is not reliable as it exposes only one // rectangular area spanning all screens. Display *display = QX11Info::display(); int x11Screen = d->isVirtualDesktop() ? DefaultScreen(display) : screen; Atom ret; int format, status; uchar* data = 0; ulong nitems, after; status = XGetWindowProperty(display, QX11Info::appRootWindow(x11Screen), atom("_NET_CLIENT_LIST"), 0L, ~0L, False, XA_WINDOW, &ret, &format, &nitems, &after, &data); if (status == Success && ret == XA_WINDOW && format == 32 && nitems) { const QRect desktopGeometry = d->rect(); Window* xids = (Window*) data; for (quint32 i = 0; i < nitems; ++i) { ulong nitems2; uchar* data2 = 0; status = XGetWindowProperty(display, xids[i], atom("_NET_WM_STRUT_PARTIAL"), 0, 12, False, XA_CARDINAL, &ret, &format, &nitems2, &after, &data2); if (status == Success && ret == XA_CARDINAL && format == 32 && nitems2 == 12) { ulong* struts = (ulong*) data2; QRect left(desktopGeometry.x(), desktopGeometry.y() + struts[4], struts[0], struts[5] - struts[4]); if (available.intersects(left)) available.setX(left.width()); QRect right(desktopGeometry.x() + desktopGeometry.width() - struts[1], desktopGeometry.y() + struts[6], struts[1], struts[7] - struts[6]); if (available.intersects(right)) available.setWidth(right.x() - available.x()); QRect top(desktopGeometry.x() + struts[8], desktopGeometry.y(), struts[9] - struts[8], struts[2]); if (available.intersects(top)) available.setY(top.height()); QRect bottom(desktopGeometry.x() + struts[10], desktopGeometry.y() + desktopGeometry.height() - struts[3], struts[11] - struts[10], struts[3]); if (available.intersects(bottom)) available.setHeight(bottom.y() - available.y()); } if (data2) XFree(data2); } } if (data) XFree(data); return available;}
开发者ID:Asmiel,项目名称:razor-qt,代码行数:79,
示例4: mainintmain (int argc, char **argv){ return top (-1) + top (1);}
开发者ID:ChrisG0x20,项目名称:gdb,代码行数:5,
示例5: popvoid pop(){ tableauDynamiqueAjouter(listeFonctionsDefinies, top()); pileEject(pileBloque);}
开发者ID:haze-sama,项目名称:wait,代码行数:5,
示例6: schedulevoid schedule(){//cs printf("activated/n"); if(Current_Thread==NULL) // Main Thread was executing previously.. { TERMINATED=0; if(!isempty(&ready_queue)) // If there are more threads... { Current_Thread=top(&ready_queue);//c printf("yes!! %p/n", Current_Thread); Global_id=Current_Thread->thread_id; swapcontext(&Main, &(Current_Thread->threads_context)); } else // If all threads are dead... {//c printf("main is getting set!/n"); setcontext(&Main); } } else //if someother thread was executing... { struct Task* tmp=next(&ready_queue, Current_Thread);//c printf("other way around and %p and current:%p/n", tmp, Current_Thread); if(tmp==NULL) //if this was the last thread in the queue.... { //execute main fn.//c printf("it was null/n"); if(TERMINATED==1) {//c printf("its gone!!/n"); TERMINATED=0; remov(&ready_queue, Global_id); Current_Thread=NULL; setcontext(&Main); } else { struct Task* tmp1=Current_Thread; Current_Thread=NULL; swapcontext(&(tmp1->threads_context), &Main); } } else { struct Task* tmp2=Current_Thread; Current_Thread=tmp; if(TERMINATED==1) { TERMINATED=0; remov(&ready_queue, Global_id); Global_id=tmp->thread_id;//c printf("context set for %p/n", tmp); setcontext(&(tmp->threads_context)); } else { Global_id=tmp->thread_id;//c printf("running:%p/n", tmp); swapcontext(&(tmp2->threads_context), &(tmp->threads_context)); } } }}
开发者ID:Pr1yanka,项目名称:OS-lab,代码行数:66,
示例7: while// reduce size so that top() != NULLvoid MotionMaster::removeEmptyTops() { while (!top() && size() > 1) // we don't want to remove last element { --i_top; }}
开发者ID:FrenchCORE,项目名称:Server,代码行数:7,
示例8: glColor3ubvoid Nonbreakable::draw(bool update){ if (type_ != REGULAR){ glColor3ub(255,204,0); glBegin(GL_POLYGON); glVertex2d(left(),bottom()); glVertex2d(right(),bottom()); glVertex2d(right(),top()); glVertex2d(left(),top()); glEnd(); if (type_ == QUESTION) { glColor3ub(255, 0, 0); glBegin(GL_POLYGON); glVertex2d(left()+6, bottom()+6); glVertex2d(left()+10, bottom()+6); glVertex2d(left()+10, bottom()+14); glVertex2d(left()+6, bottom()+14); glEnd(); glBegin(GL_POLYGON); glVertex2d(left()+6, bottom()+2); glVertex2d(left()+10, bottom()+2); glVertex2d(left()+10, bottom()+4); glVertex2d(left()+6, bottom()+4); glEnd(); } glColor3ub(0, 0, 0); glPointSize(2.0); glBegin(GL_POINTS); glVertex2d(left()+2, bottom()+2); glVertex2d(left()+2, top()-2); glVertex2d(right()-2, bottom()+2); glVertex2d(right()-2, top()-2); glEnd(); glColor3ub(0, 0, 0); glBegin(GL_LINE_LOOP); glVertex2d(left(), bottom()); glVertex2d(left(), top()); glVertex2d(right(), top()); glVertex2d(right(), bottom()); glEnd(); } else{ glColor3ub(0, 0, 0); glBegin(GL_POLYGON); glVertex2d(left(), bottom()); glVertex2d(right(), bottom()); glVertex2d(right(), top()); glEnd(); glColor3ub(199, 133, 120); glBegin(GL_POLYGON); glVertex2d(right(), top()); glVertex2d(left(), top()); glVertex2d(left(), bottom()); glEnd(); glColor3b(0, 0, 0); glBegin(GL_LINES); glVertex2d(left(), bottom()); glVertex2d(right(), top()); glEnd(); glColor3ub(199, 133, 64); glBegin(GL_LINES); glVertex2d(left(), bottom()); glVertex2d(right(), top()); glEnd(); glBegin(GL_POLYGON); glVertex2d(left()+4, bottom()+4); glVertex2d(left()+4, top()-4); glVertex2d(right()-4, top()-4); glVertex2d(right()-4, bottom()+4); glEnd(); } }
开发者ID:hydrosolar,项目名称:CS330,代码行数:92,
示例9: topMovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const { if (empty()) return IDLE_MOTION_TYPE; return top()->GetMovementGeneratorType();}
开发者ID:FrenchCORE,项目名称:Server,代码行数:6,
示例10: TableIteratorbool KoTextLayoutTableArea::layoutTable(TableIterator *cursor){ d->startOfArea = new TableIterator(cursor); d->headerRows = cursor->headerRows; d->totalMisFit = false; // If table is done we create an empty area and return true if (cursor->row == d->table->rows()) { setBottom(top()); d->endOfArea = new TableIterator(cursor); return true; } layoutColumns(); bool first = cursor->row == 0 && (d->cellAreas[0][0] == 0); if (first) { // are we at the beginning of the table cursor->row = 0; d->rowPositions[0] = top() + d->table->format().topMargin(); d->headerOffsetX = 0; d->headerOffsetY = 0; } else { for (int row = 0; row < d->headerRows; ++row) { // Copy header rows d->headerRowPositions[row] = cursor->headerRowPositions[row]; for (int col = 0; col < d->table->columns(); ++col) { d->cellAreas[row][col] = cursor->headerCellAreas[row][col]; } } if (d->headerRows) { // Also set the position of the border below headers d->headerRowPositions[d->headerRows] = cursor->headerRowPositions[d->headerRows]; } // If headerRows == 0 then the following reduces to: d->rowPositions[cursor->row] = top() d->headerOffsetY = top() - d->headerRowPositions[0]; d->rowPositions[cursor->row] = d->headerRowPositions[d->headerRows] + d->headerOffsetY; // headerOffsetX should also be set d->headerOffsetX = d->columnPositions[0] - cursor->headerPositionX; } bool complete = first; qreal topBorderWidth = 0; qreal bottomBorderWidth = 0; qreal dummyWidth = 0; collectBorderThicknesss(cursor->row - 1, dummyWidth, topBorderWidth); collectBorderThicknesss(cursor->row, topBorderWidth, bottomBorderWidth); do { qreal nextBottomBorderWidth = 0; collectBorderThicknesss(cursor->row+1, bottomBorderWidth, nextBottomBorderWidth); d->lastRowHasSomething = false; complete = layoutRow(cursor, topBorderWidth, bottomBorderWidth); setBottom(d->rowPositions[cursor->row + 1] + bottomBorderWidth); topBorderWidth = bottomBorderWidth; bottomBorderWidth = nextBottomBorderWidth; if (complete) { setVirginPage(false); cursor->row++; } } while (complete && cursor->row < d->table->rows()); if (cursor->row == d->table->rows()) { d->lastRowHasSomething = false; } if (first) { // were we at the beginning of the table for (int row = 0; row < d->headerRows; ++row) { // Copy header rows cursor->headerRowPositions[row] = d->rowPositions[row]; d->headerRowPositions[row] = d->rowPositions[row]; for (int col = 0; col < d->table->columns(); ++col) { cursor->headerCellAreas[row][col] = d->cellAreas[row][col]; } } if (d->headerRows) { // Also set the position of the border below headers cursor->headerRowPositions[d->headerRows] = d->rowPositions[d->headerRows]; d->headerRowPositions[d->headerRows] = d->rowPositions[d->headerRows]; } cursor->headerPositionX = d->columnPositions[0]; if (!virginPage() && d->totalMisFit) { //if we couldn't fit the header rows plus some then don't even try cursor->row = 0; nukeRow(cursor); } } d->endOfArea = new TableIterator(cursor); return complete;}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:100,
示例11: _int_new_arenastatic mstate_int_new_arena (size_t size){ mstate a; heap_info *h; char *ptr; unsigned long misalign; h = new_heap (size + (sizeof (*h) + sizeof (*a) + MALLOC_ALIGNMENT), mp_.top_pad); if (!h) { /* Maybe size is too large to fit in a single heap. So, just try to create a minimally-sized arena and let _int_malloc() attempt to deal with the large request via mmap_chunk(). */ h = new_heap (sizeof (*h) + sizeof (*a) + MALLOC_ALIGNMENT, mp_.top_pad); if (!h) return 0; } a = h->ar_ptr = (mstate) (h + 1); malloc_init_state (a); a->attached_threads = 1; /*a->next = NULL;*/ a->system_mem = a->max_system_mem = h->size; /* Set up the top chunk, with proper alignment. */ ptr = (char *) (a + 1); misalign = (unsigned long) chunk2mem (ptr) & MALLOC_ALIGN_MASK; if (misalign > 0) ptr += MALLOC_ALIGNMENT - misalign; top (a) = (mchunkptr) ptr; set_head (top (a), (((char *) h + h->size) - ptr) | PREV_INUSE); LIBC_PROBE (memory_arena_new, 2, a, size); mstate replaced_arena = thread_arena; thread_arena = a; __libc_lock_init (a->mutex); __libc_lock_lock (list_lock); /* Add the new arena to the global list. */ a->next = main_arena.next; /* FIXME: The barrier is an attempt to synchronize with read access in reused_arena, which does not acquire list_lock while traversing the list. */ atomic_write_barrier (); main_arena.next = a; __libc_lock_unlock (list_lock); __libc_lock_lock (free_list_lock); detach_arena (replaced_arena); __libc_lock_unlock (free_list_lock); /* Lock this arena. NB: Another thread may have been attached to this arena because the arena is now accessible from the main_arena.next list and could have been picked by reused_arena. This can only happen for the last arena created (before the arena limit is reached). At this point, some arena has to be attached to two threads. We could acquire the arena lock before list_lock to make it less likely that reused_arena picks this new arena, but this could result in a deadlock with __malloc_fork_lock_parent. */ __libc_lock_lock (a->mutex); return a;}
开发者ID:ddstreet,项目名称:glibc,代码行数:68,
示例12: heap_trimstatic intheap_trim (heap_info *heap, size_t pad){ mstate ar_ptr = heap->ar_ptr; unsigned long pagesz = GLRO (dl_pagesize); mchunkptr top_chunk = top (ar_ptr), p; heap_info *prev_heap; long new_size, top_size, top_area, extra, prev_size, misalign; /* Can this heap go away completely? */ while (top_chunk == chunk_at_offset (heap, sizeof (*heap))) { prev_heap = heap->prev; prev_size = prev_heap->size - (MINSIZE - 2 * SIZE_SZ); p = chunk_at_offset (prev_heap, prev_size); /* fencepost must be properly aligned. */ misalign = ((long) p) & MALLOC_ALIGN_MASK; p = chunk_at_offset (prev_heap, prev_size - misalign); assert (chunksize_nomask (p) == (0 | PREV_INUSE)); /* must be fencepost */ p = prev_chunk (p); new_size = chunksize (p) + (MINSIZE - 2 * SIZE_SZ) + misalign; assert (new_size > 0 && new_size < (long) (2 * MINSIZE)); if (!prev_inuse (p)) new_size += prev_size (p); assert (new_size > 0 && new_size < HEAP_MAX_SIZE); if (new_size + (HEAP_MAX_SIZE - prev_heap->size) < pad + MINSIZE + pagesz) break; ar_ptr->system_mem -= heap->size; LIBC_PROBE (memory_heap_free, 2, heap, heap->size); delete_heap (heap); heap = prev_heap; if (!prev_inuse (p)) /* consolidate backward */ { p = prev_chunk (p); unlink_chunk (ar_ptr, p); } assert (((unsigned long) ((char *) p + new_size) & (pagesz - 1)) == 0); assert (((char *) p + new_size) == ((char *) heap + heap->size)); top (ar_ptr) = top_chunk = p; set_head (top_chunk, new_size | PREV_INUSE); /*check_chunk(ar_ptr, top_chunk);*/ } /* Uses similar logic for per-thread arenas as the main arena with systrim and _int_free by preserving the top pad and rounding down to the nearest page. */ top_size = chunksize (top_chunk); if ((unsigned long)(top_size) < (unsigned long)(mp_.trim_threshold)) return 0; top_area = top_size - MINSIZE - 1; if (top_area < 0 || (size_t) top_area <= pad) return 0; /* Release in pagesize units and round down to the nearest page. */ extra = ALIGN_DOWN(top_area - pad, pagesz); if (extra == 0) return 0; /* Try to shrink. */ if (shrink_heap (heap, extra) != 0) return 0; ar_ptr->system_mem -= extra; /* Success. Adjust top accordingly. */ set_head (top_chunk, (top_size - extra) | PREV_INUSE); /*check_chunk(ar_ptr, top_chunk);*/ return 1;}
开发者ID:ddstreet,项目名称:glibc,代码行数:71,
示例13: setRangevoid QLongLongValidator::setBottom(qlonglong bottom){ setRange(bottom, top());}
开发者ID:Masstronaut,项目名称:phantom-cpp,代码行数:4,
示例14: top Object Stack<Object>::topAndPop( ) { Object topItem = top( ); pop( ); return topItem; }
开发者ID:barathsriram,项目名称:practicecodes,代码行数:6,
示例15: renderScenevoid renderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); alas(); glPopMatrix(); //bianglala glPushMatrix(); glTranslatef(-20,16,-20); glScalef(3,3,3); glRotatef(135,0,1,0); ada(); ass(); kaki(); glPushMatrix(); glRotatef(qwe,0,0,1); duduk(); glPopMatrix(); glColor3f(1.0,1.0,1.0); glPopMatrix(); /////////////////bianglala//////////////////////// //rajawali glPushMatrix(); glTranslatef(20,17,-20); glScalef(3,3,3); glRotatef(0,1,0,0); glPushMatrix(); if(asd<70){ glTranslatef( 0, asd/10, 0);} else {glTranslatef(0, fgh/10, 0);} donat(); glPopMatrix(); tiang(); glColor3f(1.0,1.0,1.0); glPopMatrix(); /////////////rajawali////////////// //hysteria glPushMatrix(); glTranslatef(20,13.5,20); glScalef(3,3,3); glPushMatrix(); if(ert<60){ glTranslatef( 0, ert/10, 0);} else {glTranslatef(0, yui/10, 0);} yangbiru(); glPopMatrix(); top(); glPopMatrix(); //////////hysteria//////////// //Menggambar Halaman glColor3f(0, 3, 0); glBegin(GL_QUADS); glVertex3f(-40.0, 0.1, -40.0); glVertex3f(-40.0, 0.1, 40.0); glVertex3f( 40.0, 0.1, 40.0); glVertex3f( 40.0, 0.1, -40.0); glEnd(); glutSwapBuffers();}
开发者ID:AfdhalZikri9,项目名称:tugasgrafkom,代码行数:68,
示例16: popvoid* pop(Stack *stack){ void *removedElement; removedElement = top(stack); stack->top = stack->top-1; return removedElement;}
开发者ID:sandesh6023,项目名称:DSA,代码行数:6,
示例17: mainint main(){ int type; double op2; double x, y, ans; char s[MAXOP]; printf(">> "); while ((type = getop(s)) != EOF) { switch (type) { case NUMBER: push(atof(s)); break; case PLUS: push(pop() + pop()); break; case TIMES: push(pop() * pop()); break; case MINUS: op2 = pop(); push(pop() - op2); break; case DIVIDE: op2 = pop(); if (op2 != 0.0) push(pop() / op2); else printf("error: zero divisor!/n"); break; case REMAIN: op2 = pop(); if (op2 != 0.0) push((double) ((long) pop() % (long) op2)); else printf("error: zero divisor!/n"); break; case TOP: top(); getch(); printf(">> "); break; case SWAP: swap(); getch(); printf(">> "); break; case CLEAR: clear(); getch(); printf(">> "); break; case SIN: push(sin(pop())); break; case COS: push(cos(pop())); break; case TAN: push(tan(pop())); break; case ASIN: push(asin(pop())); break; case ACOS: push(acos(pop())); break; case ATAN: push(atan(pop())); break; case EXP: push(exp(pop())); break; case POW: op2 = pop(); push(pow(pop(), op2)); break; case LOG: push(log(pop())); break; case LOG10: push(log10(pop())); break; case SQRT: push(sqrt(pop())); break; case X: push(x); break; case Y: push(y); break; case ANS: push(ans); break; case SETX: x = pop(); getch(); printf(">> "); break;//.........这里部分代码省略.........
开发者ID:lijiansysu,项目名称:c_practice,代码行数:101,
示例18: bottomdouble LinearRegression::gain(){ double g = bottom()!=0 ? top()/bottom():0; return (g);}
开发者ID:ndtmike,项目名称:Aggralinx,代码行数:5,
示例19: sc_mainint sc_main(int argc, char* argv[]) { Top top("top"); sc_core::sc_start(); return 0;}
开发者ID:vishal-cst,项目名称:tlm2.0,代码行数:6,
示例20: topvoid MotionMaster::InitTop(){ top()->Initialize(*i_owner); needInit[i_top] = false;}
开发者ID:AwkwardDev,项目名称:Project-WoW,代码行数:5,
示例21: make_command_treecommand_t make_command_tree(token_stream_t t){ token_t sub_head = t->head;//the sub_head is t->head token_t token_now = sub_head->next; Stack_t operators =initStack(); Stack_t operands =initStack();//build two stacks to hold operands and operators command_t comm;//one command command_t prev = NULL; int line = token_now->line; int counter=0; //if(token_now->next == NULL) // printf("Heere/n"); while(token_now!=NULL) { counter++; // printf("the %d time loop, the type is %d", counter,token_now->t_type); if( !(token_now->t_type == LEFT_DERCTION || token_now->t_type == RIGHT_DERCTION) ) { // make new command comm = (command_t)checked_malloc(sizeof( struct command )); } switch(token_now->t_type) { case AND: comm->type = AND_COMMAND; while ( !is_empty(operators) &&( top(operators)->type == PIPE_COMMAND || top(operators)->type == OR_COMMAND || top(operators)->type == AND_COMMAND )) { command_t pop_ops = pop(operators);//pop until the top ops has smaller presendence than if (!make_command_branch(pop_ops, operands)) { error(2, 0, "Line %d: Syntax error. Not enough children to create new tree.", line); return NULL; } } push(operators,comm);//push ADD command to ops token_now = token_now->next; break; case OR: comm->type = OR_COMMAND; while ( !is_empty(operators) &&( top(operators)->type == PIPE_COMMAND || top(operators)->type == OR_COMMAND || top(operators)->type == AND_COMMAND )) { command_t pop_ops = pop(operators);//pop until the top ops has smaller presendence than if (!make_command_branch(pop_ops, operands)) { error(2, 0, "Line %d: Syntax error. Not enough children to create new tree.", line); return NULL; } } push(operators,comm);//push ADD command to ops token_now = token_now->next; break; // push OR to ops push(operators,comm); break; case PIPELINE: comm->type = PIPE_COMMAND; while ( !is_empty(operators) && top(operators)->type == PIPE_COMMAND ) { command_t pop_ops = pop(operators);//pop until the top ops has smaller presendence than if (!make_command_branch(pop_ops, operands)) { error(2, 0, "Line %d: Syntax error. Not enough children to create new tree.", line); return NULL; } } push(operators,comm);//push PIPE command to ops token_now = token_now->next; break; case SEMICOLON: comm->type = SEQUENCE_COMMAND; // always pop since SEMICOLON <= all ops while (!is_empty(operators)) { command_t pop_ops = pop(operators); if (!make_command_branch(pop_ops, operands)) { error(2, 0, "Line %d: Syntax error. Not enough children to create new tree.", line); return NULL; } } // push SEMICOLON to ops push(operators,comm); token_now = token_now->next; break; case WORD: comm->type = SIMPLE_COMMAND; //seprated by word int num_words = 1; token_t count = token_now; while(count!=NULL&&count->next!=NULL&&count->next->t_type==WORD)//while next is still word//.........这里部分代码省略.........
开发者ID:summerxuan,项目名称:cs111,代码行数:101,
示例22: leftvoid coll_box::get_corners( vec2_f24p8& lt_corner, vec2_f24p8& rt_corner, vec2_f24p8& rb_corner, vec2_f24p8& lb_corner ){ lt_corner.x = lb_corner.x = left(); rt_corner.x = rb_corner.x = right(); lt_corner.y = rt_corner.y = top(); lb_corner.y = rb_corner.y = bot();}void coll_box::get_block_coords_intersected_by_corners ( vec2_s32& lt_block_coord, vec2_s32& rt_block_coord, vec2_s32& rb_block_coord, vec2_s32& lb_block_coord ){ lt_block_coord.x = lb_block_coord.x = left().round_to_int() >> 4; rt_block_coord.x = rb_block_coord.x = right().round_to_int() >> 4; lt_block_coord.y = rt_block_coord.y = top().round_to_int() >> 4; lb_block_coord.y = rb_block_coord.y = bot().round_to_int() >> 4; }
开发者ID:fl4shk,项目名称:sherwin_adventure,代码行数:24,
示例23: MoveIdlevoid MotionMaster::MoveIdle(){ if (empty() || !isStatic(top())) push(&si_idleMovement);}
开发者ID:dythzer,项目名称:mangoszero,代码行数:5,
示例24: applyIFvoid applyIF(void){ evaluatetop(); push(top()->value ? getN(2) : getN(3)); evaluatetop();}
开发者ID:remco138,项目名称:amanda,代码行数:6,
示例25: __malloc_set_stateint__malloc_set_state (void *msptr){ struct malloc_save_state *ms = (struct malloc_save_state *) msptr; size_t i; mbinptr b; disallow_malloc_check = 1; ptmalloc_init (); if (ms->magic != MALLOC_STATE_MAGIC) return -1; /* Must fail if the major version is too high. */ if ((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl)) return -2; (void) mutex_lock (&main_arena.mutex); /* There are no fastchunks. */ clear_fastchunks (&main_arena); if (ms->version >= 4) set_max_fast (ms->max_fast); else set_max_fast (64); /* 64 used to be the value we always used. */ for (i = 0; i < NFASTBINS; ++i) fastbin (&main_arena, i) = 0; for (i = 0; i < BINMAPSIZE; ++i) main_arena.binmap[i] = 0; top (&main_arena) = ms->av[2]; main_arena.last_remainder = 0; for (i = 1; i < NBINS; i++) { b = bin_at (&main_arena, i); if (ms->av[2 * i + 2] == 0) { assert (ms->av[2 * i + 3] == 0); first (b) = last (b) = b; } else { if (ms->version >= 3 && (i < NSMALLBINS || (largebin_index (chunksize (ms->av[2 * i + 2])) == i && largebin_index (chunksize (ms->av[2 * i + 3])) == i))) { first (b) = ms->av[2 * i + 2]; last (b) = ms->av[2 * i + 3]; /* Make sure the links to the bins within the heap are correct. */ first (b)->bk = b; last (b)->fd = b; /* Set bit in binblocks. */ mark_bin (&main_arena, i); } else { /* Oops, index computation from chunksize must have changed. Link the whole list into unsorted_chunks. */ first (b) = last (b) = b; b = unsorted_chunks (&main_arena); ms->av[2 * i + 2]->bk = b; ms->av[2 * i + 3]->fd = b->fd; b->fd->bk = ms->av[2 * i + 3]; b->fd = ms->av[2 * i + 2]; } } } if (ms->version < 3) { /* Clear fd_nextsize and bk_nextsize fields. */ b = unsorted_chunks (&main_arena)->fd; while (b != unsorted_chunks (&main_arena)) { if (!in_smallbin_range (chunksize (b))) { b->fd_nextsize = NULL; b->bk_nextsize = NULL; } b = b->fd; } } mp_.sbrk_base = ms->sbrk_base; main_arena.system_mem = ms->sbrked_mem_bytes; mp_.trim_threshold = ms->trim_threshold; mp_.top_pad = ms->top_pad; mp_.n_mmaps_max = ms->n_mmaps_max; mp_.mmap_threshold = ms->mmap_threshold; check_action = ms->check_action; main_arena.max_system_mem = ms->max_sbrked_mem; mp_.n_mmaps = ms->n_mmaps; mp_.max_n_mmaps = ms->max_n_mmaps; mp_.mmapped_mem = ms->mmapped_mem; mp_.max_mmapped_mem = ms->max_mmapped_mem; /* add version-dependent code here */ if (ms->version >= 1) { /* Check whether it is safe to enable malloc checking, or whether it is necessary to disable it. */ if (ms->using_malloc_checking && !using_malloc_checking && !disallow_malloc_check) __malloc_check_init (); else if (!ms->using_malloc_checking && using_malloc_checking) {//.........这里部分代码省略.........
开发者ID:AubrCool,项目名称:glibc,代码行数:101,
示例26: register3 //execute context l_thread::type_return l_thread::execute(l_call_context& context) { //lock context context.lock(); //save context register3(R_CONTEXT) = l_variable( &context ); //pc... unsigned int pc = 0; l_function& function = m_vm->function(context.get_fun_id()); l_list_command& commands = function.m_commands; //macro #define raise(str)/ {/ push_error(str, pc, (unsigned int)commands[pc].m_line);/ return T_RETURN_ERROR;/ } #define vconst(c) function.m_costants[c] #define top_size (m_top+1) //for all commands for (pc = 0; pc < commands.size(); ++pc) { //current command l_command& cmp = commands[pc]; //opcodes switch (cmp.m_op_code) { case L_JMP: pc = cmp.m_arg - 1; break; case L_RETURN: //push return if(cmp.m_arg) { //get value register3(2) = pop(); //return... return T_RETURN_VALUE; } else { //came back return T_RETURN_VOID; } //.. break; case L_IF: if(top().is_true()) { pc = cmp.m_arg - 1; } pop(); break; case L_IF0: if(top().is_false()) { pc = cmp.m_arg - 1; } pop(); break; case L_IF_OR_POP: if(top().is_true()) { pc = cmp.m_arg - 1; } else { pop(); } break; case L_IF0_OR_POP: if(top().is_false()) { pc = cmp.m_arg - 1; } else { pop(); } break; case L_PUSH: push( stack(cmp.m_arg) ); break; case L_PUSH_NULL: push( l_variable() ); break; case L_PUSH_TRUE: push( l_variable(true) ); break; case L_PUSH_FALSE: push( l_variable(false) ); break; case L_PUSHK: push( vconst(cmp.m_arg) ); break; case L_CLOSER: { //get value l_variable& call_fun = vconst(cmp.m_arg); //... if(call_fun.is_function()) { //new context register3(0) = l_closer::gc_new(get_gc()); //init context register3(0).to<l_closer>()->init(call_fun.m_value.m_fid, this, l_variable(&context));//.........这里部分代码省略.........
开发者ID:Gabriele91,项目名称:LLanguage,代码行数:101,
注:本文中的top函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ topLeft函数代码示例 C++ tone函数代码示例 |