virtual void handleMUCParticipantPresence(gloox::MUCRoom* UNUSED(room), const gloox::MUCRoomParticipant participant, const gloox::Presence& presence) { glooxwrapper::MUCRoomParticipant part; glooxwrapper::JID nick(*participant.nick); glooxwrapper::JID jid(*participant.jid); glooxwrapper::JID actor(*participant.actor); glooxwrapper::JID alternate(*participant.alternate); part.nick = participant.nick ? &nick : NULL; part.affiliation = participant.affiliation; part.role = participant.role; part.jid = participant.jid ? &jid : NULL; part.flags = participant.flags; part.reason = participant.reason; part.actor = participant.actor ? &actor : NULL; part.newNick = participant.newNick; part.status = participant.status; part.alternate = participant.alternate ? &alternate : NULL; /* MUCRoom not supported */ m_Wrapped->handleMUCParticipantPresence(NULL, part, glooxwrapper::Presence(presence.presence())); /* gloox 1.0 leaks some JIDs (fixed in 1.0.1), so clean them up */ #if GLOOXVERSION == 0x10000 delete participant.jid; delete participant.actor; delete participant.alternate; #endif }
virtual int valat(int x,int y) { float d=V2d::dist(V2d(x,y),pos); int c=d/rad; if (alternate(c)) return 255; else return 0; }
int valat(int x,int y) { V2d tofar=V2d(x,y)-pos; float d=V2d::dot(V2d::angle(ang),tofar); if (alternate(d,rad)) return 255; else return 0; }
void HEADBAND::start() { int led; int action = random(17); switch (action) { case 0: case 1: // strobe up strobe_up(); break; case 2: case 3: // strobe down strobe_down(); break; case 5: strobe_up(); strobe_down(); break; case 6: case 7: case 8: case 9: led = random(_nr_leds); _leds[led].choose(); break; case 10: glow_up(); break; case 11: glow_down(); break; case 12: glow_all(); break; case 13: blink_all(random(3)); break; case 14: shira_morse(); break; case 15: alternate(random(5) + 5); break; case 16: all_on(); break; } do_sleep(random(15) * 1000); }
bool mp4Configure(void) { uint32_t fmt=(uint32_t)muxerConfig.muxerType; bool alt=muxerConfig.useAlternateMp3Tag; diaMenuEntry format[]={{MP4_MUXER_MP4,"MP4"},{MP4_MUXER_PSP,"PSP"}}; diaElemMenu menuFormat(&fmt,QT_TRANSLATE_NOOP("mp4muxer","Muxing Format"),2,format,""); diaElemToggle alternate(&alt,QT_TRANSLATE_NOOP("mp4muxer","Use alternate MP3 tag")); diaElem *tabs[]={&menuFormat,&alternate}; if( diaFactoryRun(QT_TRANSLATE_NOOP("mp4muxer","MP4 Muxer"),2,tabs)) { muxerConfig.muxerType=(MP4_MUXER_TYPE)fmt; muxerConfig.useAlternateMp3Tag=alt; return true; } return false; }
bool WebmConfigure(void) { bool force=WebmMuxerConfig.forceDisplayWidth; uint32_t displayWidth=(uint32_t)WebmMuxerConfig.displayWidth; diaElemToggle alternate(&force,QT_TRANSLATE_NOOP("webmmuxer","Force display width")); diaElemUInteger dWidth(&displayWidth,QT_TRANSLATE_NOOP("webmmuxer","Display width"),16,65535); diaElem *tabs[]={&alternate,&dWidth}; if( diaFactoryRun(QT_TRANSLATE_NOOP("webmmuxer","Webm Muxer"),2,tabs)) { WebmMuxerConfig.forceDisplayWidth=(bool)force; WebmMuxerConfig.displayWidth=displayWidth; return true; } return false; }
int main() { int flag; char input[3]; //creating 3 node type variables new_node current and head node *new_node,*current; printf("\nEnter data to the linked list\n"); //Dynamic initializtion new_node=(node *)malloc(sizeof(node)); printf("\nEneter data to the node: "); //Storing some data scanf("%d",&new_node->data); //head pointing to the new node head=new_node; new_node->next=NULL; new_node->pre=NULL; tail=new_node; current=new_node; length++; printf("\nDo you want to enter new node(yes/no):"); scanf("%s",input); flag=string_test(input); //Iterate itself until flag is 1 i. the string entered is yes while(flag==1) { length++; //calling create_node function to create new node and link it current=create_node(current); printf("\nDo you want to enter new node(yes/no):"); scanf("%s",input); //calling string_test fuction to check whether the input is yes or no flag=string_test(input); } tail=current; //Calling the display function and passing head as the value display(head); alternate(); display(new_head); addreverse(); display(new_head); return 0; }
NFA::NFA(std::string postfixRegex) { std::queue<NFA*> nfaQueue; for (auto it = postfixRegex.cbegin(); it != postfixRegex.cend(); ++it) { switch (*it) { case '*': { NFA *n = nfaQueue.front(); nfaQueue.pop(); nfaQueue.push(kleene(n)); break; } case '&': { NFA *left = nfaQueue.front(); nfaQueue.pop(); NFA *right = nfaQueue.front(); nfaQueue.pop(); nfaQueue.push(concate(left, right)); break; } case '|': { NFA *left = nfaQueue.front(); nfaQueue.pop(); NFA *right = nfaQueue.front(); nfaQueue.pop(); nfaQueue.push(alternate(left, right)); break; } default: { nfaQueue.push(new NFA(*it)); break; }} } NFA *nfa = nfaQueue.front(); nfaQueue.pop(); assert(nfaQueue.empty()); start = nfa->start; end = nfa->end; }
/* This function should return the image frame and actions to be performed by this call * returns the animation number corresponding to this frame */ short stateUpdate(tKey* key, tObject* kid,tRoom* room) { /* TODO: check this function, it may not work in 64 bits architectures*/ tState* current=&(kid->action); /*static float step; static float acumLocation;*/ short flags; short steps; current->frame--; current->image=current->animation[current->frame]; flags =current->flags [current->frame]; steps =current->steps [current->frame]; current->imgoffx=current->offsx [current->frame]; current->mirror=flags&STATES_FLAG_M?1:0; /* BEGIN DEBUGSTATES */ #ifdef DEBUGSTATES printf("stateUpdate: animation=%d steps=%d ",current->image,steps); debugShowFlag(flags); #endif /* END DEBUGSTATES */ if (!current->frame) { int action; free(current->animation); free(current->flags); free(current->steps); free(current->offsx); /* Find matching action */ action=evaluateState(current->currentState,key,kid,room); /* Performs the events called by this action */ /* Remember the animation and flags for the next current->frame frames */ state_GetAnimation(action,current); /* Remember the state where we are now */ current->currentState=statesActionList[action].nextStateId; #ifdef DEBUGSTATES printf("NEW STATE: action=%d next=%d\n",action,current->currentState); #endif /* Move the kid (turn+traslate) */ switch(statesActionList[action].moveType) { case STATES_MOVETYPES_ABSOLUTEONSTART: /* AbsoluteOnStart (x) * Moves the kid x step units from the first forward tile change * and starts the animation there */ /* 1) move current location to the left tileChange */ kid->location-=(kid->location%STATES_STEPS_PER_TILE); /* 2) if looking right add one tile to reach the right tileChange * 3) if looking right add x, if looking left substract x */ if (kid->direction!=DIR_LEFT) kid->location+=STATES_STEPS_PER_TILE+statesActionList[action].moveOffset; else kid->location-=statesActionList[action].moveOffset; break; case STATES_MOVETYPES_ABSOLUTEONSTOP: { /* AbsoluteOnStop (x) * Deletes frames (in the middle) to make sure that, at the end of * the animation, the kid had moved only x step units from the first * forward tile change * if there is a lack of movements by frame it stops before reaching it. */ /* 1) calculate the number of frames the guy will move */ int accumulate=0; int i,j; int from,to; int moveTo=statesActionList[action].moveOffset; if (kid->direction!=DIR_LEFT) moveTo+=STATES_STEPS_PER_TILE-(kid->location%STATES_STEPS_PER_TILE); else moveTo+=kid->location%STATES_STEPS_PER_TILE; /* First iteration: determine i=number of frames not cropped */ for (i=0;(i<current->frame)&&(accumulate<=moveTo);i++) { accumulate+=current->steps[alternate(i,current->frame)]; } for (j=0;j<i;j++) { from=alternate(j,current->frame); to=alternate(j,i); if (j%2) { /* the first frames are ok, so I'll fix the last frames */ #ifdef DEBUGSTATES printf("from=%d to=%d ok\n",from,to); #endif current->animation[to]=current->animation[from]; current->flags[to]=current->flags[from]; current->steps[to]=current->steps[from]; } } #ifdef DEBUGSTATES printf("total frames=%d number of frames to be used=%d. wanted movement=%d movement to be performed=%d\n",current->frame,i,statesActionList[action].moveOffset,accumulate); #endif /* force at least one animation */ if (!i) i=1; current->frame=i; /* now the last frames are moved, crop the animation */ break; } case STATES_MOVETYPES_RELATIVETURN: /* relative but turning */ kid->direction=(kid->direction==DIR_LEFT)?DIR_RIGHT:DIR_LEFT; kid->location+=(kid->direction==DIR_LEFT)? -statesActionList[action].moveOffset: statesActionList[action].moveOffset; break; case STATES_MOVETYPES_RELATIVE: kid->location+=(kid->direction==DIR_LEFT)? -statesActionList[action].moveOffset: statesActionList[action].moveOffset; break; } } kid->location+=(kid->direction==DIR_LEFT)?-steps:steps; if ((current->frame==1) && (current->currentState<0)) return current->currentState; /* if this is the last frame of the last state, return exit code */ return flags; }