• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ deleteNode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: emptyTree

static void emptyTree(pwr_tStatus* sts, ptree_sTable* tp)
{
  pool_tRef nr;
  pool_tRef mr;

  if (tp == NULL)
    return;

  for (mr = minimumNode(tp, tp->g->root); mr != pool_cNRef;) {
    if (mr == tp->g->null)
      return;
    nr = successorNode(tp, mr);
    mr = deleteNode(tp, mr);
    freeNode(tp, mr);
    mr = nr;
  }
}
开发者ID:siamect,项目名称:proview,代码行数:17,代码来源:rt_ptree.c


示例17: main

main()
{

char cmd;   /* Command from user */
char c;
Node * head;  /* Head of the binary search tree */

head = NULL;  /* Initialize the binary search tree to be empty */

printf("Welcome to the binary search tree!\n\n");

while(1) {
   printf("Commands \n");
   printf("     (q) Quit\n");
   printf("     (e) Insert an alphabet \n");
   printf("     (d) Delete an alphabet \n");
   printf("     (t) Display tree \n");
   printf("     (i) List the nodes in in-order\n");
   printf("     (p) List the nodes in post-order\n");

   printf("Enter command: ");
   cmd = getchar();
   while(getchar() != '\n'); /* get rid of extra characters from stdin */

   if (cmd == 'q') return; /* Quit */
   else if (cmd == 'e') insertNode(&head);
   else if (cmd == 'd') deleteNode(&head); /* This is incomplete */
   else if (cmd == 't') displayTree(head);
   else if (cmd == 'i') { /* Display nodes in-order */
      printf("\n");
      printf("In-order list:");
      listInOrder(head);
      printf("\n\n");
   }
   else if (cmd == 'p') {
      printf("\n");
      printf("Post-order list:");
      /* You must implement display nodes post-order */
      listPostOrder(head);
      printf("\n\n");
   }
   else {
      printf("Invalid command, try again\n");
   }
}
}
开发者ID:storybook808,项目名称:Tree,代码行数:46,代码来源:tree.c


示例18: removeElements

 ListNode* removeElements(ListNode* head, int val) {
     ListNode dummyHead(0);
     dummyHead.next = head;//虚拟头节点,可以将删除head节点转换成一般情况,无需特殊处理
     ListNode *previous = &dummyHead;//前趋
     ListNode *current = head;
     while(current) {
         if(current->val == val) {
             deleteNode(previous, current);//删除current节点
             current = previous->next;
         }
         else {
             previous = current;
             current = current->next;
         }
     }
     return dummyHead.next;//返回真正的head
 }
开发者ID:rqy1994,项目名称:notes,代码行数:17,代码来源:remove-linked-list-elements.cpp


示例19: addNode

bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
    if (object == ui->insNum && event->type() == QEvent::KeyPress){
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if (keyEvent->key() == Qt::Key_Return){
            addNode();
            return true;
        }
        else{
            return QMainWindow::eventFilter(object, event);
        }
    }
    else if (object == ui->borrarNum && event->type() == QEvent::KeyPress){
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if (keyEvent->key() == Qt::Key_Return){
            deleteNode();
            return true;
        }
        else{
            return QMainWindow::eventFilter(object, event);
        }
    }
    else if (object == ui->buscNum && event->type() == QEvent::KeyPress){
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if (keyEvent->key() == Qt::Key_Return){
            buscarNodo();
            return true;
        }
        else{
            return QMainWindow::eventFilter(object, event);
        }
    }
    else if (object == ui->boxArchivo && event->type() == QEvent::KeyPress){
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if (keyEvent->key() == Qt::Key_Return){
            leerArchivo();
            return true;
        }
        else{
            return QMainWindow::eventFilter(object, event);
        }
    }
    else{
        return QMainWindow::eventFilter(object, event);
    }
}
开发者ID:javicuriel,项目名称:Protecto-Final,代码行数:46,代码来源:mainwindow.cpp


示例20: deleteCar

/* ===== deleteCar =====
    This function deletes the car entry
    Pre list, hash, tree
    Post nothing
 */
void deleteCar(D_LIST *list, HASH *hash, BST_TREE *tree){
	CAR car;
	char plate[50];
	char tempString[50];
    
	do{
		printf("Enter your plate number: ");
		gets(plate);
		if(strlen(plate)!=6){
			printf("Invalid input. Try Again\n");
		}
	}while(strlen(plate)!= 6);
	strcpy(car.plate, plate);
	deleteNode(list, plate);
	deleteHash(hash, plate);
	deleteTree(tree, plate);
}// deleteCar
开发者ID:xxvii27,项目名称:License-Plates-List,代码行数:22,代码来源:main.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ deleteObject函数代码示例发布时间:2022-05-30
下一篇:
C++ deleteList函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap