예제 #1
0
파일: Test.c 프로젝트: zyl111ok/DSAlgorithm
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;
}
예제 #2
0
파일: mainwindow.cpp 프로젝트: elemc/XMLer
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 );
}
예제 #3
0
파일: 01-list.c 프로젝트: xiongyejun/02-c
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;
}
예제 #4
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()));
}
예제 #5
0
파일: _LIST_.c 프로젝트: dszhengyu/C
//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;
}
예제 #6
0
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);
    }
}
예제 #7
0
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);
    }
}
예제 #9
0
파일: cursor.c 프로젝트: Shitaibin/DSAAC
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);
	}
}
예제 #10
0
void SimpleList<T>::InsertBefore(SimpleNode<T>* Ptr_, T* NewPtr_)
{
  if (Ptr_ == _List)
    AppendHead(NewPtr_);
  else
  {
    SimpleNode<T>* Node_ = FindPrevious(Ptr_);
    InsertAfter(Node_, NewPtr_);
  }
}
예제 #11
0
/* 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);
    }
}
예제 #12
0
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);
    }
}
예제 #13
0
파일: search.cpp 프로젝트: bihai/fbide
void MyFrame::OnFindAgain (wxCommandEvent& WXUNUSED(event)) {
    if (stc==0)
        return;
    int flags=FindData->GetFlags();
    if (flags & wxFR_DOWN)
        FindNext();
    else
        FindPrevious();
    return;
}
예제 #14
0
파일: list.c 프로젝트: shawnelee88/dsacc
/*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);       
	}
}
예제 #15
0
파일: List.c 프로젝트: zyl111ok/DSAlgorithm
/**
*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);
	}
}
예제 #16
0
Chapter* Chapter::FindPreviousChapter() 
{ 
	Node* CurrentNode = FindPrevious(); 
	while (CurrentNode != 0)
	{
		if (CurrentNode->IsChapter())
			return (Chapter*) CurrentNode;	  
		CurrentNode = CurrentNode->FindPrevious(); 
	}
	return 0; // No chapter found      
}                                              
예제 #17
0
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);
    }
}
예제 #18
0
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;

}
예제 #20
0
파일: list.c 프로젝트: alyadan/answer-of-D
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);
	}
}
예제 #21
0
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 );
    }
}
예제 #22
0
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);
  }
}
예제 #23
0
파일: cursor.c 프로젝트: niceforbear/lib
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);
    }
}
예제 #24
0
파일: 7.a.c 프로젝트: devilTian/Fragment
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);
	}
}
예제 #25
0
파일: _LIST_.c 프로젝트: dszhengyu/C
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);
	}
}
예제 #26
0
파일: list.c 프로젝트: 4179e1/misc
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);
	}
}
예제 #27
0
파일: list.c 프로젝트: huangqiheng/andpack
        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 );
            }
        }
예제 #28
0
파일: TravelTab.cpp 프로젝트: Ben1028/Axis2
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);
}
예제 #29
0
bool FindReplace::Find()
{
    bool found = false;

    if ( GetSearchDirection() == FindReplace::SearchDirection_Up )
    {
        found = FindPrevious();
    }
    else
    {
        found = FindNext();
    }

    return found;
}
예제 #30
0
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;
    }
}