consuming_buffers_iterator& operator++() { increment(); return *this; }
/// pre-increments the iterator iterator &operator++() { increment(); return *this; }
/// post-increments the iterator iterator operator++(int) { iterator tmp = *this; increment(); return tmp; }
//***************************************************************************** // Vp_Value_Input_Spin::handle( event) -- Event handler int Vp_Value_Input_Spin::handle( int event) { double v; int olddelta; int mx = Fl::event_x(); int my = Fl::event_y(); int sxx = x(), syy = y(), sww = w(), shh = h(); sxx += sww - buttonssize(); sww = buttonssize(); if(!indrag && ( !sldrag || !((mx>=sxx && mx<=(sxx+sww)) && (my>=syy && my<=(syy+shh)))) ) { indrag=0; switch(event) { case FL_PUSH: case FL_DRAG: sldrag=1; break; case FL_FOCUS: input.take_focus(); break; case FL_UNFOCUS: redraw(); break; case FL_KEYDOWN: if (Fl::event_key(FL_Up)) { v = increment(value(),1); handle_drag(soft()?softclamp(v):clamp(v)); return 1; } if (Fl::event_key(FL_Down)) { v = increment(value(),-1); handle_drag(soft()?softclamp(v):clamp(v)); return 1; } break; default: sldrag=0; } input.type(step()>=1.0 ? FL_INT_INPUT : FL_FLOAT_INPUT); return input.handle(event); } switch (event) { case FL_PUSH: // if (!step()) goto DEFAULT; iy = my; ix = mx; drag = Fl::event_button(); handle_push(); indrag=1; mouseobj=1; Fl::add_timeout(.25, repeat_callback, this); delta=0; if(Fl::event_inside(sxx,syy,sww,shh/2)) { deltadir=1; } else if (Fl::event_inside(sxx,syy+shh/2,sww,shh/2)) { deltadir=-1; } else { deltadir=0; } increment_cb(); redraw(); return 1; case FL_DRAG: if(mouseobj) { mouseobj=0; Fl::remove_timeout(repeat_callback, this); } // if (!step()) goto DEFAULT; olddelta=delta; delta = - (Fl::event_y()-iy); if ((delta>1) || (delta<-1) ) { deltadir=((olddelta-delta)>0)?-1:(((olddelta-delta)<0)?1:0); } else { deltadir=0; delta = olddelta;} switch (drag) { case 3: v = increment(value(), deltadir*100); break; case 2: v = increment(value(), deltadir*10); break; default:v = increment(value(), deltadir); break; } v = round(v); handle_drag(soft()?softclamp(v):clamp(v)); indrag=1; return 1; case FL_RELEASE: if(mouseobj) { Fl::remove_timeout(repeat_callback, this); } // if (!step()) goto DEFAULT; indrag=0; delta=0; deltadir=0; mouseobj=0; handle_release(); redraw(); return 1; case FL_FOCUS: indrag=0; return input.take_focus(); default: indrag=0; input.type(step()>=1.0 ? FL_INT_INPUT : FL_FLOAT_INPUT); return 1; } }
int main() { FILE *fp; big q,p,p1,h,t,g,low,high; big pool[POOL_SIZE]; BOOL fail; int i,j,p1bits,np; long seed,m,permutation; miracl *mip=mirsys(100,0); q=mirvar(0); p=mirvar(0); h=mirvar(0); t=mirvar(0); g=mirvar(0); p1=mirvar(0); low=mirvar(0); high=mirvar(0); gprime(10000); /* randomise */ printf("Enter 9 digit random number seed = "); scanf("%ld",&seed); getchar(); irand(seed); p1bits=PBITS-QBITS-1; /* find number of primes pa, pb, pc etc., that will be needed */ np=1; while (p1bits/np >= OBITS) np++; np--; /* find the high/low limits for these primes, so that the generated prime p will be exactly PBITS in length */ expb2(p1bits-1,t); nroot(t,np,low); /* np-th integer root */ incr(low,1,low); premult(t,2,t); decr(t,1,t); nroot(t,np,high); subtract(high,low,t); /* raise low limit up to half-way... */ subdiv(t,2,t); subtract(high,t,low); /* generate q */ forever { /* make sure leading two bits of q 11... */ expb2(QBITS,q); bigbits(QBITS-2,t); subtract(q,t,q); nxprime(q,q); if (logb2(q)>QBITS) continue; break; } printf("q= (%d bits)\n",logb2(q)); cotnum(q,stdout); /* generate prime pool from which permutations of np primes will be picked until a Lim-Lee prime is found */ for (i=0;i<POOL_SIZE;i++) { /* generate the primes pa, pb, pc etc.. */ pool[i]=mirvar(0); forever { bigrand(high,p1); if (mr_compare(p1,low)<0) continue; nxprime(p1,p1); if (mr_compare(p1,high)>0) continue; copy(p1,pool[i]); break; } } /* The '1' bits in the permutation indicate which primes are picked from the pool. If np=5, start at 11111, then 101111 etc */ permutation=1L; for (i=0;i<np;i++) permutation<<=1; permutation-=1; /* permuation = 2^np-1 */ /* generate p */ fail=FALSE; forever { convert(1,p1); for (i=j=0,m=1L;j<np;i++,m<<=1) { if (i>=POOL_SIZE) { /* ran out of primes... */ fail=TRUE; break; } if (m&permutation) { multiply(p1,pool[i],p1); j++; } } if (fail) break; printf("."); premult(q,2,p); multiply(p,p1,p); incr(p,1,p); permutation=increment(permutation); if (logb2(p)!=PBITS) continue; if (isprime(p)) break; } if (fail) { printf("\nFailed - very unlikely! - try increasing POOL_SIZE\n"); return 0; } printf("\np= (%d bits)\n",logb2(p)); cotnum(p,stdout); /* finally find g */ do { decr(p,1,t); bigrand(t,h); divide(t,q,t); powmod(h,t,p,g); } while(size(g)==1); printf("g= (%d bits)\n",logb2(g)); cotnum(g,stdout); fp=fopen("common.dss","wt"); fprintf(fp,"%d\n",PBITS); mip->IOBASE=16; cotnum(p,fp); cotnum(q,fp); cotnum(g,fp); fclose(fp); return 0; }
void increment_loop (void) { int i; for (i = 0; i<20000; i++) increment (); }
void drawVeraLines(){ if(numberOfLines < [[Number Of Lines]]) { drawVeraLines([[columnCounter]], [[rowCounter]]) increment(currentColumn); } else if ([[rowCounter]] < [[gridHeight]]) {
void plot_dkmax2_fib(uint32_t num_vertices, uint32_t source, FILE *gnuplot_ins, FILE *gnuplot_dm, FILE *gnuplot_total, FILE *gnuplot_dk){ printf("FibHeap: %d vertices\n",num_vertices); uint32_t **w2 = malloc(sizeof(uint32_t *)); uint32_t *weights; uint32_t **edges = generate_instance(num_vertices, w2); weights = *w2; struct timespec delmin, deck, ins, start, end; delmin.tv_nsec = 0; delmin.tv_sec = 0; deck.tv_nsec = 0; deck.tv_sec = 0; ins.tv_nsec = 0; ins.tv_sec = 0; FibHeap * heap = fib_make_heap(); uint32_t *distances = malloc(num_vertices * sizeof(uint32_t)); FibNode ** vertices = malloc(num_vertices * sizeof(FibNode *)); uint32_t distance; uint32_t *data; uint32_t i; for (i = 0; i < num_vertices; i++) { if(i == source) distance = 0; else distance = UINT_MAX; distances[i] = distance; data = malloc(sizeof(uint32_t)); *data = i; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); vertices[i] = fib_insert(distance, data, heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&ins, &start, &end); } uint32_t decrease_key_calls = 0; FibNode *node = fib_find_min(heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); fib_delete_min(heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&delmin, &start, &end); while (node) { uint32_t u = *(uint *)node->data; for (i = 1; i <= edges[u][0]; i++) { uint32_t v = edges[u][i]; uint32_t alt = distances[u] + weights[u * num_vertices + v]; if (alt < distances[v]) { clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); fib_decrease_key(distances[v] - alt, vertices[v], heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&deck, &start, &end); distances[v] = alt; decrease_key_calls++; } } node = fib_find_min(heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); fib_delete_min(heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&delmin, &start, &end); } for (i = 0; i < num_vertices; i++){ free(vertices[i]->data); free(vertices[i]); } for (i = 0; i < num_vertices; i++) free(edges[i]); free(edges); free(heap); free(vertices); free(distances); free(w2); free(weights); if(gnuplot_ins) fprintf(gnuplot_ins, "%d %ld\n", num_vertices, ((ins.tv_sec* 1000000000)+(ins.tv_nsec))/num_vertices); if(gnuplot_dm) fprintf(gnuplot_dm, "%d %ld\n", num_vertices, ((delmin.tv_sec*1000000000)+(delmin.tv_nsec))/num_vertices); if(gnuplot_dk) fprintf(gnuplot_dk, "%d %ld\n", num_vertices, ((deck.tv_sec* 1000000000)+(deck.tv_nsec))/decrease_key_calls); if(gnuplot_total) fprintf(gnuplot_total, "%d %ld\n", num_vertices, (((ins.tv_sec + delmin.tv_sec + deck.tv_sec) * 1000)+(ins.tv_nsec + delmin.tv_nsec + deck.tv_nsec)/1000000)); }
void plot_dkmax2_veb(uint32_t num_vertices, uint32_t source, FILE *gnuplot_ins, FILE *gnuplot_dm, FILE *gnuplot_total, FILE *gnuplot_dk){ printf("vEB: %d vertices\n",num_vertices); uint32_t **w2 = malloc(sizeof(uint32_t *)); uint32_t *weights; uint32_t **edges = generate_instance(num_vertices, w2); weights = *w2; struct timespec delmin, deck, ins, start, end; delmin.tv_nsec = 0; delmin.tv_sec = 0; deck.tv_nsec = 0; deck.tv_sec = 0; ins.tv_nsec = 0; ins.tv_sec = 0; //start = end = delmin = deck = ins = 0; vebtree * heap = veb_pq_init(24); uint32_t *distances = malloc(num_vertices * sizeof(uint32_t)); veb_pq_node ** vertices = malloc(num_vertices * sizeof(bh_element *)); uint32_t distance; uint32_t i; veb_pq_node *n; for (i = 0; i < num_vertices; i++) { if(i == source) distance = 0; else distance = UINT_MAX; distances[i] = distance; n = malloc(sizeof(veb_pq_node)); n->node_prio = distance; n->node_nr = i; vertices[i] = n; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); veb_pq_insert(n, heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&ins, &start, &end); } uint32_t decrease_key_calls = 0; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); n = veb_pq_deletemin(heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&delmin, &start, &end); while (n) { uint32_t u = n->node_nr; for (i = 1; i <= edges[u][0]; i++) { uint32_t v = edges[u][i]; uint32_t alt = distances[u] + weights[u * num_vertices + v]; if (alt < distances[v]) { clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); veb_pq_decrease_key(heap, vertices[v], distances[v] - alt); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&deck, &start, &end); distances[v] = alt; decrease_key_calls++; } } clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); n = veb_pq_deletemin(heap); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); increment(&delmin, &start, &end); } for (i = 0; i < num_vertices; i++) free(vertices[i]); for (i = 0; i < num_vertices; i++) free(edges[i]); free(edges); veb_destruct(heap); free(vertices); free(distances); free(w2); free(weights); if(gnuplot_ins) fprintf(gnuplot_ins, "%d %ld\n", num_vertices, ((ins.tv_sec* 1000000000)+(ins.tv_nsec))/num_vertices); if(gnuplot_dm) fprintf(gnuplot_dm, "%d %ld\n", num_vertices, ((delmin.tv_sec*1000000000)+(delmin.tv_nsec))/num_vertices); if(gnuplot_dk) fprintf(gnuplot_dk, "%d %ld\n", num_vertices, ((deck.tv_sec* 1000000000)+(deck.tv_nsec))/decrease_key_calls); if(gnuplot_total) fprintf(gnuplot_total, "%d %ld\n", num_vertices, (((ins.tv_sec + delmin.tv_sec + deck.tv_sec) * 1000)+(ins.tv_nsec + delmin.tv_nsec + deck.tv_nsec)/1000000)); }
void up_click_handler(ClickRecognizerRef recognizer, void *context) { increment(); update(); }
string StringParserandInvoker::operate(string message) { vector<string> tokens; string buf=""; unsigned int i=0; bool additionalSpace=true; message = removeNewLineCharactersAtEndOfLine(&message); while(i<message.length()) { if(message[i]!=' ') { buf+=message[i]; additionalSpace=false; } else { if(!additionalSpace) { tokens.push_back(buf); buf=""; additionalSpace=true; } } i++; } if(!buf.empty()) { tokens.push_back(buf); } /* for(i=0;i<tokens.size();i++) { cout<<tokens[i]<<endl; } cout << tokens[0] << endl; */ mapValues(); string returnVal; //cout << enumMapping[tokens[0]]<<endl; switch(enumMapping[tokens[0]]) { case putvalue: //cout << "PUT" << endl; returnVal=put(tokens); break; case getvalue: returnVal=get(tokens); break; case incrementvalue: //cout << "INCR" << endl; returnVal=increment(tokens); break; case decrementvalue: //cout << "DECR" << endl; returnVal=decrement(tokens); break; case declsamples: returnVal=declSamples(tokens); break; case declmovavg: returnVal=declMovAvg(tokens); break; case addsamples: returnVal=addSamples(tokens); break; case movavg: returnVal=movingAvg(tokens); break; case retrieve: returnVal = retrieveN(tokens); break; case variance: returnVal=getvariance(tokens); break; case stddev: returnVal=getstddev(tokens); break; case lifetimeavg: returnVal=getlifetimeavg(tokens); break; case histogram: returnVal = getHistogram(tokens); break; default: returnVal="Invalid input"; break; } return returnVal; }
MMappedFileRecordArrayIterator(MMappedRecordReader<T> &&reader, size_t elcnt) : value_(NULL), reader_(std::move(reader)), elcnt_(elcnt), good_(true) { increment(); }
void main() { clrscr(); cout<<"\n\tHashing Technique used Snefru"; cout<<"\n\tHash File Test.txt "; int32 ip[16],op[16],bitLength[2] = {0,0}, counter=0; char str[48],ch; int i; fstream fin("test.txt",ios::in|ios::binary); FILE *hash = fopen("hash.txt","wt"); while(!fin.eof()) { for(i=0; i<4; i++) op[i] = 0; fin>>str; bitLength[1] = bitLength[0] = 0; increment(bitLength,8*strlen(str)); for(i=0;i<4;i++) ip[i] = op[i]; for(counter=0; (counter+48) <= (bitLength[1]/8); counter+=48) { convert(str,counter,ip); //print(ip,16); hash512(op,ip,8); for(i=0;i<4;i++) ip[i] = op[i]; } if(counter*8 < bitLength[1]) { counter += (bitLength[1]/8); while(counter%48!=0) str[counter++] = 0; convert(str,(counter-48),ip); //print(ip,16); hash512(op,ip,8); for(i=0;i<4;i++) ip[i] = op[i]; } //print(ip,16); ip[14] = bitLength[0]; ip[15] = bitLength[1]; //print(ip,16); hash512(op,ip,8); cout<<endl<<setw(10)<<setfill(' ')<<str<<" "; print(op,4); fprintf(hash,"%10s ",str); for(int j=0;j<4;j++) fprintf(hash,"%08lx ",op[j]); fprintf(hash,"\n"); } getch(); }
void MSEntryFieldCombo::armUpArrow(void) { _upArrow->select(MSTrue); increment(); startDelayTimer(Up); }