void CMenuSpawn::RemapMenu(HMENU hMenu) { static int iRecurse = 0; iRecurse ++; CMenu pMenu; pMenu.Attach(hMenu); ASSERT(pMenu); int nItem = pMenu.GetMenuItemCount(); while ((--nItem)>=0) { UINT itemId = pMenu.GetMenuItemID(nItem); if (itemId == (UINT) -1) { CMenu pops(pMenu.GetSubMenu(nItem)); if (pops.GetHandleMenu()) RemapMenu(pops.GetHandleMenu()); if (bIsPopup || iRecurse > 0) { TCHAR cs[128]; memset(cs,0x00,128); pMenu.GetMenuString(nItem, cs, 128,MF_BYPOSITION); if (lstrlen(cs)>0) { SpawnItem * sp = AddSpawnItem(cs, (!bIsPopup && iRecurse == 1) ? -4 : -2); pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW, (UINT) -1, (LPCTSTR)sp); } } } else { if (itemId != 0) { UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION); if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP)) { ASSERT(oldState != (UINT)-1); TCHAR cs[128]; memset(cs,0x00,128); pMenu.GetMenuString(nItem, cs, 128, MF_BYPOSITION); SpawnItem * sp = AddSpawnItem(cs, itemId); if (itemId!=SC_CLOSE) pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp); } } else { UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION); if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP)) { ASSERT(oldState != (UINT)-1); SpawnItem * sp = AddSpawnItem("--", -3); pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp); } } } } iRecurse --; pMenu.Detach(); }
void DelOddNodes(LINK* x) { int count=1; LINK *y=NULL; int temp; while(x!=NULL) { if(count%2==1) { if(x!=list) temp = deleteaftr(y); // Previous Node // else temp = pops(); } y = x; x = x->next; count++; } }
void ConsumerStateTable::pop(KeyOpFieldsValuesTuple &kco, std::string prefix) { if (m_buffer.empty()) { pops(m_buffer, prefix); } if (m_buffer.empty()) { auto& values = kfvFieldsValues(kco); values.clear(); kfvKey(kco).clear(); kfvOp(kco).clear(); return; } kco = m_buffer.front(); m_buffer.pop_front(); }
main(void) { int ch,e,pos,temp=0,ct=1,end=FALSE; list = NULL; LINK *x; LINK *p; // Creating a Header Node (Info part contains number of elements) // // List points to Header Node // p = getnode(); p->info = 0; p->right = p; p->left = p; list = p; while(1) { system("cls"); printf("\n\n\nHeader Doubly Circular Linked List Implementation Using Dynamic Variables\n\n"); printf("1. Insert Elements\n"); printf("2. Delete Elements\n"); printf("3. Display Elements\n"); printf("4. Exit\n\n"); printf("Enter Choice:"); scanf("%d",&ch); switch(ch) { case 1: printf("\nEnter Element:"); scanf("%d",&e); if(emptys()) pushs(e); else { printf("\nEnter Element Position:"); scanf("%d",&pos); if(pos>count+1 || pos<=0) printf("\nIncorrect Position!"); else inserts(e,pos); fflush(stdin); getchar(); } break; case 2: ct=1; if(emptys()) { printf("\nUnderflow!"); fflush(stdin); getchar(); } else { printf("\nEnter Element to Delete:"); scanf("%d",&e); x=list; while(end == FALSE) // only 1 condition required since LL always contains Header Node { x = x->right; if(x->info==e) { if(x!=list->right) // list.next is first node temp = deletes(x); // Previous Node // else temp=pops(); printf("\n%d Deleted at Position %d !",temp, ct); } if(x->right==list) { x=list; end = TRUE; } ct++; } end = FALSE; if(x==list && temp==0) printf("\nElement Does Not Exist"); fflush(stdin); getchar(); } break; case 3: x = list->right; if(!emptys()) printf("\nLinked List(Number of Nodes:%d):",list->info); while(end==FALSE && !emptys()) { printf("%d->",x->info); x = x->right; if(x==list) end = TRUE; } end = FALSE; if(emptys()) printf("\nLinked List Empty!"); fflush(stdin); getchar(); break; case 4: exit(0); // returning 0 means successful } } }
main(void) { int ch,e,pos,temp=0,ct=1,count1=0; LINK *x; LINK *y; list=NULL; while(1) { system("cls"); printf("\n\nLinked List Implementation Using Dynamic Variables\n"); printf("--------------------------------------------------\n\n"); printf("1. Insert Elements\n"); printf("2. Delete Elements\n"); printf("3. Display Elements\n"); printf("4. Count No. of Nodes\n"); printf("5. Reverse Linklist\n"); printf("6. Delete Alternate Nodes\n"); printf("7. Exit\n\n"); printf("Enter Choice:"); scanf("%d",&ch); switch(ch) { case 1: printf("\nEnter Element:"); scanf("%d",&e); if(emptys()) pushs(e); else { printf("\nEnter Element Position:"); scanf("%d",&pos); if(pos>count+1 || pos<=0) printf("\nIncorrect Position!"); else insertaftr(e,pos); fflush(stdin); getchar(); } break; case 2: ct=1; if(emptys()) { printf("\nUnderflow!"); fflush(stdin); getchar(); } else { printf("\nEnter Element to Delete:"); scanf("%d",&e); x=list; while(x!=NULL) { if(x->info==e) { if(x!=list) temp = deleteaftr(y); // Previous Node // else temp=pops(); printf("\n%d Deleted at Position %d !",temp, ct); //x = list; //ct=1; } y = x; x=x->next; ct++; } if(x==NULL && temp==0) printf("\nElement Does Not Exist"); fflush(stdin); getchar(); } break; case 3: x = list; if(list!=NULL) printf("\nLinked List:"); while(x!=NULL) { printf("%d->",x->info); x = x->next; } if(list==NULL) printf("\nLinked List Empty!"); fflush(stdin); getchar(); break; case 4: x = list; count1 = 0; while(x!=NULL) { count1++; x = x->next; } printf("\n\nNo. of Nodes:%d",count1); getch(); break; case 5: if(emptys()) { printf("\n\nLinked List Empty!"); getch(); break; } Reverses(list); printf("\n\nLinked List Reversed!"); getch(); break; case 6: if(emptys()) { printf("\n\nUnderflow!"); getch(); break; } printf("\n\n1. Even Nodes"); printf("\n2. Odd Nodes"); printf("\n\nEnter Choice:"); fflush(stdin); scanf("%d",&ch); switch(ch) { case 1: DelEvenNodes(list); printf("\n\nEven Nodes Deleted!"); break; case 2: DelOddNodes(list); printf("\n\nOdd Nodes Deleted!"); break; default: printf("\n\nInvalid Choice!"); } getch(); break; case 7: exit(0); // returning 0 means successful } } }
main(void) { int ch,e,pos,temp=0,ct=1; LINK *x; LINK *y; list=NULL; while(1) { system("cls"); printf("\n\n\nDoubly Linked List Implementation Using Dynamic Variables\n\n"); printf("1. Insert Elements\n"); printf("2. Delete Elements\n"); printf("3. Display Elements\n"); printf("4. Exit\n\n"); printf("Enter Choice:"); scanf("%d",&ch); switch(ch) { case 1: printf("\nEnter Element:"); scanf("%d",&e); if(emptys()) pushs(e); else { printf("\nEnter Element Position:"); scanf("%d",&pos); if(pos>count+1 || pos<=0) printf("\nIncorrect Position!"); else inserts(e,pos); fflush(stdin); getchar(); } break; case 2: ct=1; if(emptys()) { printf("\nUnderflow!"); fflush(stdin); getchar(); } else { printf("\nEnter Element to Delete:"); scanf("%d",&e); x=list; while(x!=NULL) { if(x->info==e) { if(x!=list) temp = deletes(x); // Current Node // else temp = pops(); printf("\n%d Deleted at Position %d !",temp, ct); } x=x->right; ct++; } if(x==NULL && temp==0) printf("\nElement Does Not Exist"); fflush(stdin); getchar(); } break; case 3: x = list; if(list!=NULL) printf("\nLinked List:"); while(x!=NULL) { printf("%d->",x->info); x = x->right; } if(list==NULL) printf("\nLinked List Empty!"); fflush(stdin); getchar(); break; case 4: exit(0); // returning 0 means successful } } }
static void make_peekdata_ops(peekdata_data& dt, const std::string& s) { std::auto_ptr<peekdata_ops> pops(new peekdata_ops()); std::string tok; for (size_t i = 0; i < s.size(); ++i) { char ch = s[i]; if (ch == ',') { pops->opsrcs.push_back(tok); tok.clear(); } else { tok.push_back(ch); } } pops->opsrcs.push_back(tok); for (size_t i = 0; i < pops->opsrcs.size(); ++i) { const std::string& src = pops->opsrcs[i]; if (src.empty()) { dt.err = "invalid op [" + src + "]"; return; } peekdata_op *op = 0; if (src == "add") { op = new peekdata_op_binop<std::plus<unsigned long>, false>(); } else if (src == "sub") { op = new peekdata_op_binop<std::minus<unsigned long>, false>(); } else if (src == "mul") { op = new peekdata_op_binop<std::multiplies<unsigned long>, false>(); } else if (src == "div") { op = new peekdata_op_binop<std::divides<unsigned long>, true>(); } else if (src == "mod") { op = new peekdata_op_binop<std::modulus<unsigned long>, true>(); } else if (src == "and") { op = new peekdata_op_binop<std::bit_and<unsigned long>, false>(); } else if (src == "or") { op = new peekdata_op_binop<std::bit_or<unsigned long>, false>(); } else if (src == "xor") { op = new peekdata_op_binop<std::bit_xor<unsigned long>, false>(); } else if (src == "land") { op = new peekdata_op_binop<std::logical_and<unsigned long>, false>(); } else if (src == "lor") { op = new peekdata_op_binop<std::logical_or<unsigned long>, false>(); } else if (src == "eq") { op = new peekdata_op_binop<std::equal_to<unsigned long>, false>(); } else if (src == "ne") { op = new peekdata_op_binop<std::not_equal_to<unsigned long>, false>(); } else if (src == "gt") { op = new peekdata_op_binop<std::greater<unsigned long>, false>(); } else if (src == "ge") { op = new peekdata_op_binop<std::greater_equal<unsigned long>, false>(); } else if (src == "lt") { op = new peekdata_op_binop<std::less<unsigned long>, false>(); } else if (src == "le") { op = new peekdata_op_binop<std::less_equal<unsigned long>, false>(); } else if (src.substr(0, 4) == "outd") { op = new peekdata_op_out_decimal(read_longval(src, 4)); } else if (src.substr(0, 4) == "outh") { op = new peekdata_op_out_hexadecimal(read_longval(src, 4)); } else if (src.substr(0, 4) == "outs") { op = new peekdata_op_out_string(read_longval(src, 4)); } else if (src.substr(0, 5) == "outsz") { op = new peekdata_op_out_nulterm_string(read_longval(src, 5)); } else if (src.substr(0, 5) == "ind") { op = new peekdata_op_in_decimal(read_longval(src, 3)); } else if (src.substr(0, 5) == "inh") { op = new peekdata_op_in_hexadecimal(read_longval(src, 3)); } else if (src.substr(0, 2) == "ld") { op = new peekdata_op_peek(strtoul(src.c_str() + 2, 0, 0)); } else if (src.substr(0, 2) == "cp") { op = new peekdata_op_copy(strtoul(src.c_str() + 2, 0, 0)); } else if (src.substr(0, 2) == "po") { op = new peekdata_op_pop(strtoul(src.c_str() + 2, 0, 0)); } else if (src[0] == 'j') { op = new peekdata_op_jmp<false>(strtol(src.c_str() + 1, 0, 0)); } else if (src.substr(0, 2) == "cj") { op = new peekdata_op_jmp<true>(strtol(src.c_str() + 2, 0, 0)); } else if (src[0] >= '0' && src[0] <= '9') { op = new peekdata_op_ulong(strtoul(src.c_str(), 0, 0)); } else if (src[0] == '@') { std::string symstr(src.c_str() + 1); dt.syms[symstr]; op = new peekdata_op_sym(symstr); } else if (src == "tr") { dt.trace_flag = true; } else if (src.substr(0, 4) == "elim") { dt.exec_limit = strtoul(src.c_str() + 4, 0, 0); } else if (src.substr(0, 4) == "slim") { dt.string_limit = strtoul(src.c_str() + 4, 0, 0); } else { dt.err = "invalid op [" + src + "]"; } if (op != 0) { pops->ops.push_back(op); } } dt.ops = pops; }