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


C++ eat函数代码示例

本文整理汇总了C++中eat函数的典型用法代码示例。如果您正苦于以下问题:C++ eat函数的具体用法?C++ eat怎么用?C++ eat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: philosopher_fn

void philosopher_fn(void* no){
    int i = (int)no;
    int right,count;
    right = (i+1)%NUM_CHOPSTICKS;
    for(count=0;count<NUM_ROUNDS;count++){
    printf("Philosopher %d going to think [%d]\n",i,count);
    think();
    sem_wait(&four_chairs);
    printf("Philosopher %d occupied a chair [%d]\n",i,count);
    pthread_mutex_lock(&mutex_arr[i]);
    pthread_mutex_lock(&mutex_arr[right]);
    printf("Philosopher %d locked chopsticks [%d]\n",i,count);
    printf("Philosopher %d going to eat [%d]\n",i,count);
    eat();
    printf("Philosopher %d going to unlock chopsticks [%d]\n",i,count);
    pthread_mutex_unlock(&mutex_arr[right]);
    pthread_mutex_unlock(&mutex_arr[i]);
    sem_post(&four_chairs);
    printf("Philosopher %d gave up a chair [%d]\n",i,count);
    }
}
开发者ID:gjpalathingal,项目名称:gjworks,代码行数:21,代码来源:diners_pblm_sem.c

示例2: readID

static Obj *readName( istream& is )
{
	string s = readID( is );

	if( s == "true" ) {
		return new BooleanObj( true );
	} else if( s == "false" ) {
		return new BooleanObj( false );
	} else {
		if( !eat( is ) ) {
			return new IdObj( s );
		}

		int ch = is.peek();
		if( strchr( "}),;", ch ) != NULL ) {
			return new IdObj( s );
		} else {
			return new NamedObj( s, readObject( is ) );
		}
	}
}
开发者ID:cychiuae,项目名称:recart-3tcetjorp-1144pmoc,代码行数:21,代码来源:parse.cpp

示例3: compileType

Type* compileType(void) {
  Type* type;
  Type* elementType;
  int arraySize;
  Object* obj;

  switch (lookAhead->tokenType) {
  case KW_INTEGER: 
    eat(KW_INTEGER);
    type =  makeIntType();
    break;
  case KW_CHAR: 
    eat(KW_CHAR); 
    type = makeCharType();
    break;
  case KW_ARRAY:
    eat(KW_ARRAY);
    eat(SB_LSEL);
    eat(TK_NUMBER);

    arraySize = currentToken->value;

    eat(SB_RSEL);
    eat(KW_OF);
    elementType = compileType();
    type = makeArrayType(arraySize, elementType);
    break;
  case TK_IDENT:
    eat(TK_IDENT);
    obj = checkDeclaredType(currentToken->string);
    type = duplicateType(obj->typeAttrs->actualType);
    break;
  default:
    error(ERR_INVALID_TYPE, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
  return type;
}
开发者ID:leaderwing,项目名称:test_repo,代码行数:38,代码来源:parser.c

示例4: eat

IMPLEMENT
int
Pic::irq_pending()
{
  unsigned int i;

  for (i = 0; i < highest_irq; i++)
    pfd[i].revents = 0;

  if (poll(pfd, highest_irq, 0) > 0)
    for (i = 0; i < highest_irq; i++)
      if (pfd[i].revents & POLLIN)
        {
	  if (!Emulation::idt_vector_present(0x20 + i))
            eat(i);
          else
            return i;
	}

  return -1;
}
开发者ID:KyulingLee,项目名称:Fiasco.OC,代码行数:21,代码来源:pic-ux.cpp

示例5: main

int main()
{
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);  //标准输出句柄获得
	SetConsoleCursorInfo(hOut, &cur_info);  //隐藏光标
	while(1)
	{
		system("cls");/*清屏*/
		Snake* head = (Snake*)malloc(sizeof(Snake));
		initialization(head);
		background();
		while(1)
		{
			Sleep(500);
			refresh();
			getkeys();
			run(head);
			eat(head);
			if(door(head)) break;
			food(head);
		}
		release_list(head);
		SetConsoleCursorPosition(hOut, pos);
		SetConsoleTextAttribute(hOut, 0x07);
		system("cls");/*清屏*/
		printf("得分:%d\n空格重新开始\n",scoring);
		while(1)
		{
			int w = getch();
			if(w == ' ')
			{
				break;
			}
			else
			{
				continue;
			}
		}
	}
	return 0;
}
开发者ID:mjjOpencode2015,项目名称:My-Repository,代码行数:40,代码来源:Snake1.c

示例6: FACTOR

void FACTOR(void){
	/*factor 	::= 	<CONST_INT>
	| 	<CONST_FLOAT>
	| 	<CONST_BOOLEAN>
	| 	id restof_functioncall_or_epsilon
	| 	"(" assignment ")"*/
	switch(l){

	case CONST_INT:																	eat(CONST_INT);  return;
	case CONST_FLOAT:																eat(CONST_FLOAT); return;
	case CONST_BOOLEAN:																eat(CONST_BOOLEAN); return;
	case ID:																		eat(ID); RESTOF_FUNCTIONCALL_OR_EPSILON(); return;
	case '(':																		eat('('); ASSIGNMENT(); eat(')'); return;
	default:																		StdError(__func__);
	}
}
开发者ID:Bakkhos,项目名称:compilers,代码行数:16,代码来源:minako-syntax.c

示例7: compileType

Type* compileType(void) {
  Type* type;
  Type* elementType;
  int arraySize;
  Object* obj;

  switch (lookAhead->tokenType) {
  case KW_INTEGER: 
    eat(KW_INTEGER);
    type =  makeIntType();
    break;
  case KW_CHAR: 
    eat(KW_CHAR); 
    type = makeCharType();
    break;
  case KW_ARRAY:
    eat(KW_ARRAY);
    eat(SB_LSEL);
    eat(TK_NUMBER);

    arraySize = currentToken->value;

    eat(SB_RSEL);
    eat(KW_OF);
    elementType = compileType();
    type = makeArrayType(arraySize, elementType);
    break;
  case TK_IDENT:
    eat(TK_IDENT);
    // TODO: check if the type idntifier is declared and get its actual type
    break;
  default:
    error(ERR_INVALID_TYPE, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
  return type;
}
开发者ID:BichVN,项目名称:Compiler,代码行数:37,代码来源:parser.c

示例8: while

void Snake::init()
{
	con->clear();
	for (int i = 0; i < WIDTH; ++i)
		for (int j = 0; j < HEIGHT; ++j)
		{
			B[i][j] = 0;
		}

	for (int i = intLeft; i <= intRight; ++i)
	{
		con->putChar('*',i,intTop - 1);
		con->putChar('*',i,intBottom + 1);
		B[i][intTop - 1] = B[i][intBottom + 1] = -1; 
	}

	for (int i = intTop; i <= intBottom; ++i)
	{
		con->putChar('*',intLeft - 1,i);
		con->putChar('*',intRight + 1,i);
		B[intLeft - 1][i] = B[intRight + 1][i] = -1;
	}
	while (!snakeBody.empty()) snakeBody.pop();
	curDirect =  D_EAST;

	int midX = (intRight - intLeft) / 2 + intLeft;
	int midY = (intBottom - intTop) / 2 + intTop;

	snakeHead.X = midX;
	snakeHead.Y = midY;

	B[midX][midY] = -1;

	con->putChar(SNAKE_CHAR, snakeHead.X, snakeHead.Y);

	snakeBody.push(snakeHead);

	eat(D_EAST);
}
开发者ID:PhamHoangVu,项目名称:SnakeGame,代码行数:39,代码来源:Snake.cpp

示例9: compileExpression

void compileExpression(void) {
  assert("Parsing an expression");
  // TODO
  switch (lookAhead->tokenType) {
  case SB_PLUS:
  case SB_MINUS:
    eat(lookAhead->tokenType);
    compileExpression2();
    break;
  case TK_IDENT:
  case TK_CHAR:
  case TK_NUMBER:
  case SB_LPAR:
  case TK_STRING:
    compileExpression2();
    break;
  default:
    error(ERR_INVALIDEXPRESSION, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
  assert("Expression parsed");
}
开发者ID:BichVN,项目名称:Compiler,代码行数:22,代码来源:parser.c

示例10: compileType

void compileType(void) {
  switch(lookAhead->tokenType){
  case KW_INTEGER:
      eat(KW_INTEGER);
      break;
  case KW_CHAR:
      eat(KW_CHAR);
      break;
  case KW_ARRAY:
      eat(KW_ARRAY);
      eat(SB_LSEL);
      eat(TK_NUMBER);
      eat(SB_RSEL);
      eat(KW_OF);
      compileType();
      break;
  case TK_IDENT://type ident
      eat(TK_IDENT);
      break;
  default :
    error(ERR_INVALIDTYPE, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
}
开发者ID:duccuongict56bkhn,项目名称:CompilerLab,代码行数:24,代码来源:parser.c

示例11: __pyx_init_filenames

/* Implementation of cimport */

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initcimport(void); /*proto*/
PyMODINIT_FUNC initcimport(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("cimport", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)Py_None); Py_INCREF(Py_None);
  __pyx_ptype_3pkg_4eggs_Eggs = __Pyx_ImportType("pkg.eggs", "Eggs", sizeof(struct __pyx_obj_3pkg_4eggs_Eggs)); if (!__pyx_ptype_3pkg_4eggs_Eggs) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; goto __pyx_L1;}

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":7 */
  eat(__pyx_v_7cimport_yummy);

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":8 */
  tons = 3.14;

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":9 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_pkg); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_eggs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_ova, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":10 */
  __pyx_1 = PyObject_CallObject(((PyObject *)__pyx_ptype_3pkg_4eggs_Eggs), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_7cimport_fried));
  __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)__pyx_1);
  __pyx_1 = 0;
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("cimport");
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:47,代码来源:cimport.c

示例12: game

void game(HGame *game)//전체게임함수
{
	int current_player = 0;
	while(true)
	{
		//인터페이스 : e(exit), b(잔고), h(키설명),save(저장).load
		
		//eat함수 
		eat();

		//상태갱신

		//점수산출score함수
		score();

		//났나? - 났을 때 고 혹은 스톱

		//스톱시 stop함수

		//턴 넘기기
		++current_player;
	}
}
开发者ID:Phryxia,项目名称:SSU_Hwatoo,代码行数:23,代码来源:Projectmain.c

示例13: while

void ImageEaterThread::run() {
    QImage* image;
    m_alive = true;
    while(m_alive) {
        m_mutexSleep.lock();
        m_condition.wait(&m_mutexSleep, m_rate);
        m_mutexSleep.unlock();
        image = eat();
        if (image != NULL && m_alive) {
            // TODO : when main window dies, m_renderTarget is deallocated
            // shared mutex ? (testing only for m_alive is not guaranteed)
            m_renderTarget->setPixmap(QPixmap::fromImage(*image));

            //allows for dynamic buffersize change and more robust when heavy lag
            if(m_numberImage < m_bufferSize) {
                m_condition.wakeAll();
            }

            delete image;
            emit imageEaten();
        }
    }
}
开发者ID:ciolben,项目名称:asmv,代码行数:23,代码来源:imageeaterthread.cpp

示例14: peek

QString GaduEmoticonParser::parseQuoted()
{
	QChar c = peek();
	if (c == '"')
	{
		eat();
		int quoteIndex = EmoticonLine.indexOf('"', Index);
		if (quoteIndex < 0)
			return getToIndex(EmoticonLine.length());
		else
			return getToIndex(quoteIndex);
	}

	int bracketIndex = EmoticonLine.indexOf(')', Index);
	int comaIndex = EmoticonLine.indexOf(',', Index);
	int endIndex = bracketIndex < 0
			? comaIndex
			: comaIndex < 0
					? bracketIndex
					: qMin(bracketIndex, comaIndex);

	return getToIndex(endIndex);
}
开发者ID:leewood,项目名称:kadu,代码行数:23,代码来源:gadu-emoticon-parser.cpp

示例15: _eat_item_on_floor

bool _eat_item_on_floor()
{
    // Don't steal stuff by eating them
    auto tile = get_tile_at(current_dungeon, player.pos.x, player.pos.y);
    if (tile->properties & TILE_PROP_SHOP)
    {
        return false;
    }

    std::vector<item_t*> food_on_ground;

    for (item_t* item : current_dungeon->items)
    {
        if (item->pos.x == player.pos.x && item->pos.y == player.pos.y && item->type == ITEM_TYPE_FOOD)
        {
            food_on_ground.push_back(item);
        }
    }

    for (item_t* food : food_on_ground)
    {
        if (yesno(format("There is a %s here. Eat it?", food->get_item_name().c_str()), true))
        {
            eat(&player, food);
            food->stacksize--;
            if (food->stacksize == 0)
            {
                remove_item(current_dungeon, food, true);
            }

            return true;
        }
    }

    return false;
}
开发者ID:smarmy,项目名称:HellRogue,代码行数:36,代码来源:game.cpp


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