当前位置: 首页>>代码示例>>C++>>正文


C++ deleteNode函数代码示例

本文整理汇总了C++中deleteNode函数的典型用法代码示例。如果您正苦于以下问题:C++ deleteNode函数的具体用法?C++ deleteNode怎么用?C++ deleteNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了deleteNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: practice89

void practice89(list_t list)
{

	node_t* nodePtr;

	printf("\n값이 40인 노드 삭제하는 함수\n헤드가 없을때까지 계속 헤드를 삭제하는 함수\n\n");
	printf("전체 리스트\n");
	printAllNodes(&list);
	nodePtr = searchNode(&list, 40);
	deleteNode(&list, findPrevNode(&list, nodePtr), nodePtr);
	printf("값이 40인 노드 삭제\n");
	printAllNodes(&list);
	printf("헤드가 없어질때까지 헤드를 삭제\n");
	while (list.head)
	{
		deleteNode(&list, (node_t*)NULL, list.head);
		printAllNodes(&list);
	}

	fflush(stdin);
	getchar();

	return;
}
开发者ID:ozt88,项目名称:NEXT_14_FIRST,代码行数:24,代码来源:linked_list.c

示例2: main

/* function main begins program execution */
int main(void)
{ 
   int i; /* counter to loop from 1-10 */
   int item; /* variable to hold random values */
   TreeNodePtr rootPtr = NULL; /* tree initially empty */

   srand( time( NULL ) ); 
   printf( "The numbers being placed in the tree are:\n" );

   /* insert random values between 1 and 15 in the tree */
   for ( i = 1; i <= 10; i++ ) { 
      item = 1 + rand() % 10;
      printf( "%3d", item );
      insertNode( &rootPtr, item );
   } /* end for */

   printf("\n\nInsert the value to remove: ");
   scanf("%d", &item);

   if( deleteNode( &rootPtr, item ) ) {
      printf("Value not found or value is root: %d\n", item);
      return -1;
   }

   /* traverse the tree preOrder */
   printf( "\nThe preOrder traversal is:\n" );
   preOrder( rootPtr );

   /* traverse the tree inOrder */
   printf( "\n\nThe inOrder traversal is:\n" );
   inOrder( rootPtr );

   /* traverse the tree postOrder */
   printf( "\n\nThe postOrder traversal is:\n" );
   postOrder( rootPtr );

   /* traverse the tree levelOrder */
   printf( "\n\nThe levelOrder traversal is:\n" );
   levelOrder( rootPtr );

   puts("\n\nShow the tree\n\n");
   outputTree(rootPtr, 0);

   putchar('\n');

   return 0; /* indicates successful termination */

} /* end main */
开发者ID:clamiax,项目名称:misc,代码行数:49,代码来源:outputTree.c

示例3: main

void main()
{
	int i, choice = 1;
	startNode = NULL;

	while (choice != 0)
	{
		puts("Please select an option:\n");
		puts("---------------------------------------");
		puts("01\tInsert a Node");
		puts("02\tDelete a Node");
		puts("03\tDisplay all Nodes");
		puts("04\tSearch for a Node");
		puts("\n00\tExit");
		puts("---------------------------------------\n");

		fflush(stdin);
		scanf_s("%d", &choice);

		switch (choice)
		{
		case 1:
			insertNode();
			break;

		case 2:
			deleteNode();
			break;

		case 3:
			displayAll();
			break;

		case 4:
			findNode();
			break;

		case 0:
			break;

		default:
			puts("Invalid selection!\n");
			break;
		}
	}
	free(startNode);
	free(currentNode);
}
开发者ID:worhello,项目名称:CollegeCode,代码行数:48,代码来源:labWeek20.c

示例4: main

int main()
{
struct node * head=NULL;

printf("hello main");



head=pushele(5,head);
head=pushele(15,head);
head=appendHead(10,head);
head=deleteNode(2,head);
printList(head);
return 0;

}
开发者ID:kaushikankur,项目名称:LinkedList,代码行数:16,代码来源:linklistinsert.c

示例5: removeUpperCase

//TODO
//Read List.h to help you look at the hints
//remove values which are uppercase
//
//given a list X
//(Empty List)
//then removeUpperCase(list);
//the list is still X
//
//given a list a->X
//then removeUpperCase(list);
//the list is a->X
//
//given a list A->X
//then removeUpperCase(list);
//the list is X
//
//given a list A->a->X
//then removeUpperCase(list);
//the list is a->X
//
//given a list C->a->A->D->X
//then removeUpperCase(list);
//the list is a->X
//
//given a list A->a->B->b->C->c->d->D->E->e->X
//then removeUpperCase(list);
//the list is a->b->c->d->e->X
void removeUpperCase(List l) {
   assert(l != NULL);
   Node curr = l->head;
   Node prev = NULL;
   while(curr != NULL) {
       if (curr->value >= 'A' && curr->value <= 'Z') {
           Node next = curr->next;
           deleteNode(l, prev, curr);
           curr = next;
        } else {
            prev = curr;
            curr = curr->next;
        }
   }
   printList(l);
}
开发者ID:nicolargh,项目名称:COMP1917,代码行数:44,代码来源:ListSol.c

示例6: emptyTree

static void
emptyTree(pwr_tStatus *sts, tree_sTable *tp)
{
    tree_sNode *np;
    tree_sNode *mp;
  
    if (tp == NULL) return;

    for (mp = minimumNode(tp, tp->root); mp != NULL;) {
        if (mp == tp->null) return;
        np = successorNode(tp, mp);
        mp = deleteNode(tp, mp);
        freeNode(tp, mp);
	mp = np;
    }
}
开发者ID:Strongc,项目名称:proview,代码行数:16,代码来源:co_tree.c

示例7: main

int main()
{
    FILE *f=fopen("input.txt","r");
    if(f==NULL)
    {
        perror("Can't open file!\n");
        return -1;
    }
    NodeT *root=createBinTree(f);
    AVLTree(root);
    root=insertNode(root,11);
    root=deleteNode(root,11);
    prettyPrint(root,0);

    return 0;
}
开发者ID:alungeipaula,项目名称:DSA-lab,代码行数:16,代码来源:main.c

示例8: main

int main(void)
{
    NODE *start=NULL;
    insert(&start,10);
    insert(&start,20);
    insert(&start,30);
    insert(&start,40);
    insert(&start,50);
    insert(&start,60);
    display(start);
 //   firstLastReverse(&start);
    largestLast(&start);
    smallestFirst(&start);
    deleteNode(&start,40);
    display(start);
    return 0;
}
开发者ID:ashishdoneriya,项目名称:MyPrograms,代码行数:17,代码来源:main.c

示例9: deleteEdges

/*
 * Deletes any edges to a vertex in a binary tree
 */
void deleteEdges(binTreeNode_t * pBinaryNode, int tarVertID)
{
    /* delete the edge in this node */
    if(pBinaryNode->value != NULL)
    {
        deleteNode((linkedList_t *) pBinaryNode->value, tarVertID);
    }
    /* run this function recursivly on all children */
    if(pBinaryNode->left != NULL)
    {
        deleteEdges(pBinaryNode->left, tarVertID);
    }
    if(pBinaryNode->right != NULL)
    {
        deleteEdges(pBinaryNode->right, tarVertID);
    }
}
开发者ID:chloe747,项目名称:AA_Assignment_1,代码行数:20,代码来源:binaryTree.c

示例10: main

int main(int argc, char **argv)
{
    struct ListNode n6 = {1, NULL},
                    n5 = {2, &n6},
                    n4 = {3, &n5},
                    n3 = {3, &n4},
                    n2 = {2, &n3},
                    n1 = {1, &n2},
                    n0 = {1, &n4},
                    *res;
    int is_res;
    print(&n0);
    print(&n1);
    deleteNode(&n3);
    print(&n1);
    return 0;
}
开发者ID:uangyy,项目名称:leetcode,代码行数:17,代码来源:work.c

示例11: internalRemove

 int internalRemove(const ObjType &u) {
   // returns index of extracted object, or -1 if not there.
   int hashval = computeHash(u);
   SET_NODE* sn = hashTable[hashval];
   SET_NODE** pLast = &(hashTable[hashval]);
   while (sn) {
     if (sn->u == u) {
       int idx = sn->idx;
       *pLast = sn->next;
       deleteNode(sn);
       return idx;
     }
     pLast = &(sn->next);
     sn = sn->next;
   }
   return -1;
 }
开发者ID:busjaeger,项目名称:cs410sp12,代码行数:17,代码来源:PSet.hpp

示例12: main

/* Drier program to test above functions*/
int main()
{
    /* Start with the empty list */
    struct node* head = NULL;
 
    push(&head, 7);
    push(&head, 1);
    push(&head, 3);
    push(&head, 2);
 
    puts("Created Linked List: ");
    printList(head);
    deleteNode(&head, 1);
    puts("\nLinked List after Deletion of 1: ");
    printList(head);
    return 0;
}
开发者ID:ketan936,项目名称:college-work,代码行数:18,代码来源:list_delete.c

示例13: main

int main(){
	int option = 999;
	char *menuStr = getScrOp();
	while(option!=11){
		printf("%sEnter an Option :",menuStr);
		scanf("%d",&option);
		switch(option){
			case 1:
				insert();
				break;
			case 10:
				display();
				break;
			case 2:
				InsertBegin();
				break;
			case 3:
				InsertAnywhere();
				break;
			case 11:
				printf("Exited.");
				break;
			case 4:
				deleteNode();
				break;
			case 5:
				countIteratively();
				break;
			case 6:
				getNth();
				break;
			case 7:
				searchIteratively();
				break;
			case 8:
				searchRecursively(head,getInput());
				break;
			case 9:
				swapByLinks();
				break;
			default :
				printf("Enter an valid option");
		}
	}
	return 0;
}
开发者ID:nithish,项目名称:mycodes,代码行数:46,代码来源:LinkedList-Traversal.c

示例14: deleteNode

BDDCalculator &BDDCalculator::operator=(const BDDCalculator &obj)
{
	if(m_proot)
	{
		m_proot -> m_counter--;
		if(m_proot -> m_counter == 0)
		{
			deleteNode(m_proot -> m_pnode);
			delete m_proot;
		}
	}

	m_proot = obj.m_proot;
	m_proot -> m_counter++;

	return *this;
}
开发者ID:anjin-viktor,项目名称:changeable-cipher,代码行数:17,代码来源:DisForm.cpp

示例15: freeMarker

/** Destructor */
GGraph::~GGraph()
{
    freeMarker( nodeTextIsShown);
    for ( GNode *node = firstNode();
          isNotNullP( node);
          )
    {
        GNode* next = node->nextNode();
        int ir_id = node->irId();
        deleteNode( node);
        node = next;
    }
    foreach ( GStyle *style, styles)
    {
        delete style;
    }
}
开发者ID:KavenFan,项目名称:codequery,代码行数:18,代码来源:graph_view.cpp


注:本文中的deleteNode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。