int sl_delete(skiplist* S, int k) { node* p = sl_search(S, k); if(p->key != k) return 0; int level = 1; node* q = p; while (q->down != NULL) { q = q->down; level++; } node* temp = S->top; int i = g_level; while (i++ > level) { temp = temp->down; } node* pre_p = temp; temp = S->top; while (1) { while (temp->right->key < k) { temp = temp->right; } if (temp->right == p) { break; } temp = temp->down; } temp->right = p->right; while (temp->down != NULL) { temp = temp->down; while (temp->right->key < k) { temp = temp->right; } temp->right = temp->right->right; } int need_shrink = 0; temp = pre_p->down; node* r = pre_p; while (r->key == temp->key) { if ((r->right == NULL) && (temp->right == NULL)) { need_shrink = 1; break; } if ((r->right == NULL) || (temp->right == NULL)) { break; } r = r->right; temp = temp->right; } temp = pre_p->down; while (pre_p != NULL) { pre_p->down = temp->down; pre_p = pre_p->right; temp = temp->right; } return 0; }
void EnzymesADVContext::initViewContext(GObjectView* view) { AnnotatedDNAView* av = qobject_cast<AnnotatedDNAView*>(view); ADVGlobalAction* a = new ADVGlobalAction(av, QIcon(":enzymes/images/enzymes.png"), tr("Find restriction sites..."), 50); a->setObjectName("Find restriction sites"); a->addAlphabetFilter(DNAAlphabet_NUCL); connect(a, SIGNAL(triggered()), SLOT(sl_search())); GObjectViewAction *createPCRProductAction = new GObjectViewAction(av, av, tr("Create PCR product...")); createPCRProductAction->setObjectName(CREATE_PCR_PRODUCT_ACTION_NAME); connect(createPCRProductAction, SIGNAL(triggered()), SLOT(sl_createPCRProduct())); addViewAction(createPCRProductAction); }
void HMMADVContext::initViewContext(GObjectView* view) { AnnotatedDNAView* av = qobject_cast<AnnotatedDNAView*>(view); ADVGlobalAction* a = new ADVGlobalAction(av, QIcon(":/hmm2/images/hmmer_16.png"), tr("Find HMM signals with HMMER2..."), 70); connect(a, SIGNAL(triggered()), SLOT(sl_search())); }