本文整理汇总了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);
}
}
示例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 ) );
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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__);
}
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}
}
示例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");
}
示例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;
}
}
示例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();
}
}
}
示例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);
}
示例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;
}