int main() { int a[5]={1,2,3,4,5}; //Test init data by HeadInserting List Head=Create(a,5); //output the whole list print(Head); //Test init data by TailInserting List Tail=TailCreate(a,5); print(Tail); //Test Reversing the linkedList List Reversed= Reverse(Tail); print(Reversed); Reverse(Tail); //Test Find Element Function Position P=Find(2,Tail); printf("%d\n",P->Element); //Test FindPrevious Function printf("%d\n",FindPrevious(2,Tail)->Element); //Test insert Function Position s=Find(3,Tail); Insert(9,Tail,s); print(Tail); //Test Delete Function Delete(9,Tail); print(Tail); return 0; }
void MainWindow::initialActions() { initialActionsIcons(); initialActionsShortcuts(); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openDocumentAction())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveDocumentAction())); connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAsDocumentAction())); connect(ui->actionProperties, SIGNAL(triggered()), this, SLOT(propertiesAction())); connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeDocumentAction())); connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(ui->actionCopy, SIGNAL(triggered()), this, SLOT(copyNodeAction())); connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(findAction())); connect(ui->actionFindNext, SIGNAL(triggered()), findWidget, SLOT(FindNext())); connect(ui->actionFindPrevious, SIGNAL(triggered()), findWidget, SLOT(FindPrevious())); // bookmarks connect(ui->actionBookmark, SIGNAL(triggered()), this, SLOT(bookmarkToggled())); connect(ui->actionBookmarkGotoNext, SIGNAL(triggered()), model, SLOT(bookmarkNext())); connect(ui->actionBookmarkGotoPrevious, SIGNAL(triggered()), model, SLOT(bookmarkPrev())); // view connect( ui->actionCollapseAll, SIGNAL(triggered()), this, SLOT(collapseAll()) ); connect( ui->actionExpandAll, SIGNAL(triggered()), this, SLOT(expandAll()) ); // FIXME: it's a temporary ui->actionNew->setVisible( false ); }
int main() { List L; Position P; int X; L = (Position) malloc(sizeof(struct Node)); L->Next = NULL; L->Element = -1; initList(L); printf("print list:\n"); PrintList(L); return 0; printf("input a num:"); scanf("%d", &X); P = FindPrevious(X, L); if(P == NULL) printf("can't find the num:%d previous num\n", X); else printf("Previous num is:%d, address is :0x%p\n", P->Element, P->Next); DeleteList(L); return 0; }
FindDock::FindDock(QWidget *parent) : QDockWidget(parent), ui(new Ui::FindDock) { ui->setupUi(this); connect(ui->findPreviousButton, SIGNAL(clicked()), this, SLOT(FindPrevious())); connect(ui->findNextButton, SIGNAL(clicked()), this, SLOT(FindNext())); }
//exec 3.3.a void swapNeighborNode(List L, Position P1, Position P2) { Position tmp; tmp = FindPrevious(P1->Element, L); tmp->Next = P2; P1->Next = P2->Next; P2->Next = P1; }
void Delete(ElementType X, List L){ Position P, TmpCell; P = FindPrevious(X, L); if(!IsLast(P, L)){ TmpCell = P->Next; P->Next = TmpCell->Next; free(TmpCell); } }
BOOL NodeAttribute::IsEffectAttribute() const { // Node* pSibling = FindPrevious(CC_RUNTIME_CLASS(NodeRenderableBounded)); Node* pSibling = FindPrevious(); while (pSibling && !pSibling->IsBounded()) pSibling = pSibling->FindPrevious(); return (pSibling!=NULL); }
void Delete(ElementType X, List L) { Position p=FindPrevious(X, L), temp; if(!isLast(p, L)){ //注意这句判断,如果p是last,那么说明没有找到X,即List中不存在X结点 temp=p->next; p->next=temp->next; free(temp); } }
void Delete(ElementType X, List L) { Position pre = FindPrevious(X, L); if (pre) { Position t = CursorSpace[pre].Next; CursorSpace[pre].Next = CursorSpace[t].Next; CursorFree(t); } }
void SimpleList<T>::InsertBefore(SimpleNode<T>* Ptr_, T* NewPtr_) { if (Ptr_ == _List) AppendHead(NewPtr_); else { SimpleNode<T>* Node_ = FindPrevious(Ptr_); InsertAfter(Node_, NewPtr_); } }
/* Delete first occurance of X * */ void Delete(int X, List L){ Position P,tmp; P = FindPrevious(X, L); if(!IsLast(P, L)){ tmp = P->next; P->next = tmp->next; free(tmp); } }
void Delete(int x,List L)//删除链表中的x元素 { Position P,TmpCell; P=FindPrevious(x, L); if (!IsLast(P, L)) { TmpCell=P->Next; P->Next=TmpCell->Next; free(TmpCell); } }
void MyFrame::OnFindAgain (wxCommandEvent& WXUNUSED(event)) { if (stc==0) return; int flags=FindData->GetFlags(); if (flags & wxFR_DOWN) FindNext(); else FindPrevious(); return; }
/*delete first occurrence of e from list L*/ void Delete(List L, ElemType e) { Position P, tmp; P = FindPrevious(L, e); if(!IsLast(P, L)){ //e is found, delete it tmp = P->next; P->next = tmp->next; free(tmp); } }
/** *delete the node where the value=x */ void Delete(int X,List L) { Position P ,TmpNode; P=FindPrevious(X,L); if(!IsLast(P)) { TmpNode=P->Next; P->Next=TmpNode->Next; free(TmpNode); } }
Chapter* Chapter::FindPreviousChapter() { Node* CurrentNode = FindPrevious(); while (CurrentNode != 0) { if (CurrentNode->IsChapter()) return (Chapter*) CurrentNode; CurrentNode = CurrentNode->FindPrevious(); } return 0; // No chapter found }
void Delete(int x, List L) { Position p, Tmp; p = FindPrevious(x, L); if (!IsLast(p, L)) { Tmp = p->Next; p->Next = Tmp->Next; free(Tmp); } }
void Delete(int X,List L){ Position preNode; if ((preNode=FindPrevious(X, L))!=NULL) { Position tempNode=preNode->next; preNode->next=tempNode->next; tempNode->element=0; tempNode->next=NULL; free(tempNode); } }
void InsertPrevious(ElementType X,ElementType Y,List L,Position P) { //在position之前插入 Position Pre,Tmpcell; Tmpcell = malloc(sizeof(struct Node)); if(Tmpcell == NULL) FatalError("Out of space!!!\n"); Pre = FindPrevious(P -> coefficient,P -> exponent ,L); Tmpcell -> Next = Pre -> Next; Pre -> Next = Tmpcell; }
void Delete(int x, List L) { Position P, TemCell; P = FindPrevious(x, L); if( !IsLast(P,L)){ TemCell = P->Next; P->Next = TemCell->Next; free(TemCell); } }
void Delete( ElementType X, adjustList L ) { Position Pre; Pre = FindPrevious( X, L ); if( !IsLast( Pre, L ) ) { Position TmpCell = Pre->Next; Pre->Next = TmpCell->Next; free( TmpCell ); } }
void Delete(List L, ElementType X){ Position P, tmpCell; P = FindPrevious(L, X); if ( !IsLast(L,P)) { tmpCell = P->next; P->next = tmpCell->next; free(tmpCell); } }
void Delete(ElementType X, List L){ Position P, TmpCell; P = FindPrevious(X, L); if(!IsLast(P, L)){ // Assumption of header use TmpCell = CursorSpace[P].Next; CursorSpace[P].Next = CursorSpace[TmpCell].Next; CursorFree(TmpCell); } }
void Delete(ElementType X, List L) { Position p, temp; p = FindPrevious(X, L); if (IsLast(p->next, L)) { p->next = NULL; } else { // error: p->next = p->next->next; temp = p->next; p->next = temp->next; free(temp); } }
void Delete(ElementType X, List L) { Position P, temp; P = FindPrevious(X, L); if (P != NULL) { temp = P->Next; P->Next = temp->Next; free(temp); } }
void Delete (ListElementType X, List L) { Position P, TmpCell; P = FindPrevious (X, L); if (!IsLast (P, L)) { TmpCell = CursorSpace[P].Next; CursorSpace[P].Next = CursorSpace[TmpCell].Next; CursorFree (TmpCell); } }
void Delete( ElementType X, List L ) { Position P, TmpCell; P = FindPrevious( X, L ); if( !IsLast( P, L ) ) /* Assumption of header use */ { /* X is found; delete it */ TmpCell = P->Next; P->Next = TmpCell->Next; /* Bypass deleted cell */ free( TmpCell ); } }
BOOL CTravelTab::PreTranslateMessage(MSG* pMsg) { if ( pMsg->message == WM_KEYDOWN ) { if ( pMsg->wParam == VK_F3 ) { if ( GetAsyncKeyState(VK_SHIFT) ) FindPrevious(); else Find(); return TRUE; } } return CDockingPage::PreTranslateMessage(pMsg); }
bool FindReplace::Find() { bool found = false; if ( GetSearchDirection() == FindReplace::SearchDirection_Up ) { found = FindPrevious(); } else { found = FindNext(); } return found; }
void Find( ElementType X, adjustList L ) { Position Pre, P; Pre = FindPrevious( X, L ); if( Pre->Next == NULL ) Error( "Not found element" ); else { P = Pre->Next; // Delete Pre->Next = P->Next; // 插入表头 P->Next = L->Next; L->Next = P; } }