/* insertions move set*/ PRIVATE int insertions(Encoded *Enc, struct_en *str, struct_en *minim){ int cnt = 0; short *pt = str->structure; int len = pt[0]; int i,j; for (i=1; i<=len; i++) { if (pt[i]==0) { for (j=i+1; j<=len; j++) { /* end if found closing bracket*/ if (pt[j]!=0 && pt[j]<j) break; /*')'*/ if (pt[j]!=0 && pt[j]>j) { /*'('*/ j = pt[j]; continue; } /* if conditions are met, do insert*/ if (try_insert(pt, Enc->seq, i, j)) { Enc->bp_left=i; Enc->bp_right=j; if (Enc->noLP) { /* if lone bases occur, try inserting one another base*/ if (lone_base(pt, i) || lone_base(pt, j)) { /* inside*/ if (try_insert(pt, Enc->seq, i+1, j-1)) { Enc->bp_left2=i+1; Enc->bp_right2=j-1; cnt += update_deepest(Enc, str, minim); /* in case useFirst is on and structure is found, end*/ if (Enc->first && cnt > 0) return cnt; } else /*outside*/ if (try_insert(pt, Enc->seq, i-1, j+1)) { Enc->bp_left2=i-1; Enc->bp_right2=j+1; cnt += update_deepest(Enc, str, minim); /* in case useFirst is on and structure is found, end*/ if (Enc->first && cnt > 0) return cnt; } } else { cnt += update_deepest(Enc, str, minim); /* in case useFirst is on and structure is found, end*/ if (Enc->first && cnt > 0) return cnt; } } else { cnt += update_deepest(Enc, str, minim); /* in case useFirst is on and structure is found, end*/ if (Enc->first && cnt > 0) return cnt; } } } } } return cnt; }
// insertions move set int insertions(encoded &enc, int &deepest, short *min_pt, degen °, bool verbose) { int cnt = 0; short *pt = enc.pt; int len = pt[0]; for (int i=1; i<=len; i++) { if (pt[i]==0) { for (int j=i+1; j<=len; j++) { // end if found closing bracket if (pt[j]!=0 && pt[j]<j) break; //')' if (pt[j]!=0 && pt[j]>j) { //'(' j = pt[j]; continue; } // if conditions are met, do insert if (try_insert(pt, enc.seq, i, j)) { enc.bp_left=i; enc.bp_right=j; if (deg.opt->noLP) { // if lone bases occur, try inserting one another base if (lone_base(pt, i) || lone_base(pt, j)) { // inside if (try_insert(pt, enc.seq, i+1, j-1)) { enc.bp_left2=i+1; enc.bp_right2=j-1; cnt += update_deepest(enc, deepest, min_pt, deg, verbose); // in case useFirst is on and structure is found, end if (deg.opt->first && cnt > 0) return cnt; } else //outside if (try_insert(pt, enc.seq, i-1, j+1)) { enc.bp_left2=i-1; enc.bp_right2=j+1; cnt += update_deepest(enc, deepest, min_pt, deg, verbose); // in case useFirst is on and structure is found, end if (deg.opt->first && cnt > 0) return cnt; } } else { cnt += update_deepest(enc, deepest, min_pt, deg, verbose); // in case useFirst is on and structure is found, end if (deg.opt->first && cnt > 0) return cnt; } } else { cnt += update_deepest(enc, deepest, min_pt, deg, verbose); // in case useFirst is on and structure is found, end if (deg.opt->first && cnt > 0) return cnt; } } } } } return cnt; }
/* insertions move set*/ PRIVATE int insertions(Encoded *Enc, struct_en *str, struct_en *minim){ int cnt = 0; short *pt = str->structure; int len = pt[0]; int i,j; if (Enc->verbose_lvl>1) { fprintf(stderr, " "); print_str(stderr, str->structure); fprintf(stderr, " %5d Insertions:\n", str->energy); } for (i=1; i<=len; i++) { if (pt[i]==0) { for (j=i+1; j<=len; j++) { /* end if found closing bracket*/ if (pt[j]!=0 && pt[j]<j) break; /*')'*/ if (pt[j]!=0 && pt[j]>j) { /*'('*/ j = pt[j]; continue; } /* if conditions are met, do insert*/ if (try_insert(pt, Enc->seq, i, j)) { Enc->bp_left=i; Enc->bp_right=j; if (Enc->noLP) { /* if lone bases occur, try inserting one another base*/ if (lone_base(pt, i, j)) { /* try only inside insert -- not to repeat structures*/ if (try_insert(pt, Enc->seq, i+1, j-1)) { /* but now, check if this second insert does not extend the stem */ if (pt[i+2] != 0 && pt[i+2] == pt[j-2]) continue; Enc->bp_left2=i+1; Enc->bp_right2=j-1; } else continue; } } // finally insert: cnt += update_deepest(Enc, str, minim); /* in case useFirst is on and structure is found, end*/ if (Enc->first && cnt > 0) return cnt; } } } } return cnt; }
void insert(T const& v) { maybe_enlarge(); T* idx = lookup(v.key()); if(idx) idx->assign_value(v); else { while(!try_insert(v)) enlarge(); } }
void rehash(std::vector<T>& e) { deleted = 0; // There will be no deleted elements afterwards try_insert: elems = 0; for(std::size_t i = 0; i < e.size(); ++i) { if(e[i].is_filled() && !try_insert(e[i])) { // We need to make the table larger tsize = next_prime(tsize + 1); t.assign(tsize, T()); goto try_insert; } } }