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


C++ DeleteNode函数代码示例

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


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

示例1: DeleteItem

//删除元素
BOOL DeleteItem(Item * pi,Tree * ptree)
{
	Pair look;

	look = SeekItem(pi,ptree);//在树中查找目标项目,成功则返回包含目标项目的父节点和当前节点的指针的结构体
	if(look.child == NULL)
	{
		return FALSE;
	}
	if(!DeQueue(pi,look.child->queue) || look.child->queue->end == NULL)//目标节点的队列为空,或删除首元素后目标节点的队列为空
	{
		if(look.parent == NULL)
		{
			DeleteNode(&ptree->root);
		}
		else if(look.parent->left == look.child)
		{
			DeleteNode(&look.parent->left);
		}
		else if(look.parent->right == look.child)
		{
			DeleteNode(&look.parent->right);
		}
		ptree->size--;
	}
	else//当前目标节点的队列不为空,删除成功
	{
		puts("Delete pet's inforamtion succesfully!");
	}
	return TRUE;
}
开发者ID:18616378431,项目名称:myCode,代码行数:32,代码来源:8tree.c

示例2: DeleteNodeNth

/* Delete Nth Node from list */
void DeleteNodeNth(Node **top, int n) {
    // ここに解答を書き加える
    // nが1ならはじめの要素を消す
    if (n == 1) {
        DeleteNode(top);
        return;
    }
    Node *ptr = *top;
    int count = 1;
    while (ptr->next != NULL) {
        ptr = ptr->next;
        count++;
    }
    // nが要素数より大きい時
    if (n > count)
        return;

    if (ptr == NULL)
        return;

    ptr = *top;

    Node backup = *ptr;
    Node temp;
    int i;
    for (i = 0; i < n - 1; i++) {
        ptr = ptr->next;

        SetNode(&temp, ptr->no, ptr->name, NULL);
        SetNode(ptr, backup.no, backup.name, ptr->next);
        SetNode(&backup, temp.no, temp.name, NULL);
    }

    DeleteNode(top);
}
开发者ID:DrakeBrunner,项目名称:scratches,代码行数:36,代码来源:llist-plus.c

示例3: if

void BinarySearchTree::DeleteNode( TreePtr & treePtr, DATA_TYPE val )
{

  if( treePtr == NULL )
    {
      return;
    }
  else if (val == treePtr->data )
    {
      DeleteNodeItem( treePtr );
    }
  else if (val < treePtr->data )
    {
      cout << "DeleteNode::treePtr->data: " << treePtr->data<< endl;
      cout < "   Looking left" << endl;
      DeleteNode (treePtr->leftPtr, val );
    }
  else 
    {
      cout << "DeleteNode::treePtr->data: " << treePtr->data << endl;
      cout << "  Looking right " << endl;
   
      DeleteNode (treePtr->rightPtr, val );  
    }
}
开发者ID:ccasey645,项目名称:OldMachine,代码行数:25,代码来源:BSTree.cpp

示例4: if

void BinarySearchTree::DeleteNode(
                     TreePtr& treePtr, DATA_TYPE val )
{
#ifdef  DEBUG_DELETE
   cout << "DeleteNode::val:  " << val << endl;
#endif

   if( treePtr == NULL )
   {
      return;
   }
   else if( val == treePtr->data )
   {
      DeleteNodeItem( treePtr );
          //  was rootPtr---unexpected results
   }
   else if( val < treePtr->data )
   {
#ifdef  DEBUG_DELETE
      cout << "DeleteNode::treePtr->data:  " << treePtr->data << endl;
      cout << "     looking left" << endl;
#endif
      
      DeleteNode( treePtr->leftPtr, val );
   }
   else
   {
#ifdef  DEBUG_DELETE
      cout << "DeleteNode::treePtr->data:  " << treePtr->data << endl;
      cout << "     looking right" << endl;
#endif
      
      DeleteNode( treePtr->rightPtr, val );
   }
}
开发者ID:engrnasirkhan,项目名称:UofI,代码行数:35,代码来源:BSTree2.cpp

示例5: FindNodeEntry

/*
 *  Returns the full xTEDS for the corresponding xTEDS provider in Message.  A successful call to
 *  this method also frees the xTEDSSegmentNode.
 *	Params:
 *		Message - The provider with which to match the xTEDS
 *		xTEDSOut [OUTPUT] - Pointer to the buffer to store the xTEDS, this must be at least XTEDS_MAX_SIZE
 *		MaxSize - The size of xTEDSOut
 *	Returns:
 *		bool - True upon success, false is some error occurred
*/
bool xTEDSSegmentBuilder::GetFullxTEDS(const SDMxTEDS &Message, char *xTEDSOut, int MaxSize)
{
	//First, be sure that the xTEDS is fully built, and that xTEDSOut is not NULL
	if (!CheckIsFinished(Message) || xTEDSOut == NULL)
		return false;
	
	//Now we can return the xTEDS
	xTEDSSegmentNode *SegmentNode = FindNodeEntry(Message.source);
	//To be safe, see that we have the node (this should have been handled above)
	if (SegmentNode == NULL)
		return false;
	
	//Check to see that the DM's xTEDS buffer will be big enough
	if (strlen(SegmentNode->xTEDSBuffer) > static_cast<unsigned int>(MaxSize))
	{
		printf("Data Manager not built to support xTEDS of size %d (only up to %d) bytes.\n",strlen(SegmentNode->xTEDSBuffer),MaxSize);
		DeleteNode(Message.source);
		return false;
	}
	//Copy the xTEDS
	else
		strcpy(xTEDSOut, SegmentNode->xTEDSBuffer);
	
	//At this point, the xTEDS has been received, release the node
	DeleteNode(Message.source);
	
	return true;
}
开发者ID:NKSG,项目名称:vn-sdm,代码行数:38,代码来源:xTEDSSegmentBuilder.cpp

示例6: DeleteNodeIntervals

void CIntervalTree::ClearNode(TTreeNode* node)
{
    DeleteNodeIntervals(node->m_NodeIntervals);

    DeleteNode(node->m_Left);
    DeleteNode(node->m_Right);
    node->m_Left = node->m_Right = 0;
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:8,代码来源:itree.cpp

示例7: DeleteNode

void SpatialGraph::DeleteNode( SpatialGraphKDNode* pNode )
{
	if( pNode == NULL )
		return;

	DeleteNode( pNode->LHC );
	DeleteNode( pNode->RHC );

	delete pNode;
}
开发者ID:MrSnowman,项目名称:angel2d,代码行数:10,代码来源:SpatialGraph.cpp

示例8: DeleteNode

/**
 * 习题6.45,对于二叉树中每个元素值为x的结点,删除以它为根的子树,并释放相应结点空间
 */
void DeleteNode(BiTree &T, TElemType x)
{
	if (T) {
		if (T->data == x)
			DestroyTree(T); 
		else {
			DeleteNode(T->lchild, x);
			DeleteNode(T->rchild, x);
		}
	}
}
开发者ID:Annie2333,项目名称:DS_Code,代码行数:14,代码来源:practice.cpp

示例9: main

// Ö÷º¯Êý
int main(void)
{
	int pos;

	printf("TEST 1...\n");
	LinkList *plist = CreateLinkList( );				// 创建单链表
	for(int pos = 0; pos < LIST_SIZE; pos++)			// 循环向单链表中插入数据
	{
		InsertNode(plist, pos, pos + 1);
	}
	ShowList(plist);									// 插入结束后显示单链表的信息

	DeleteNode(plist, 0);								// 删除第一个元素
	ShowList(plist);
	DeleteNode(plist, 1);								// 删除第二个元素
	ShowList(plist);

	ClearLinkList(plist);								// 将单链表清空
	ShowList(plist);
	DestroyLinkList(plist);								// 将单链表销毁
	plist = NULL;

	printf("\n\nTEST 2...\n");
	LinkList list;
	InitLinkList(&list);								// 初始化单链表
	for(int pos = 0; pos < LIST_SIZE; pos++)			// 训话向单链表中插入数据
	{
		InsertNode(&list, pos, pos + 1);
	}
	ShowList(&list);									// 显示单链表
	ClearLinkList(&list);								// 清空单链表
//	FinitLinkList(&list);		// ERROR== list->m_head->m_next == NULL
	ShowList(&list);

	printf("\n\nTEST 3...\n");
	LinkListNode *prevNode = &list;			// 带头结点的单链表头指针是list->m_next
	LinkListNode *addNode = NULL;
	for(int pos = 0; pos < LIST_SIZE; pos++)
	{
		if((addNode = AddNode(&list, prevNode, pos + 1)) != NULL)
		{
            prevNode = addNode;
		}
	}
	ShowList(&list);
	while(IsEmptyLinkList(&list) != true)			// 循环删除单链表中的数据
	{
		DeleteCurrNode(&list, list.m_next);
	}
	ShowList(&list);									// 显示单链表

	return 	EXIT_SUCCESS;
}
开发者ID:gatieme,项目名称:DataStructures,代码行数:54,代码来源:main.c

示例10: ParentFlush

static void ParentFlush(BOOLEAN prnt_flush, OBJECT dest_index, BOOLEAN kill)
{ OBJECT prnt;
  debug3(DGF, DD, "ParentFlush(%s, %s, %s)",
    bool(prnt_flush), EchoIndex(dest_index), bool(kill));
  if( prnt_flush )
  { Parent(prnt, Up(dest_index));
    if( kill )  DeleteNode(dest_index);
    debug0(DGF, DD, "  calling FlushGalley from ParentFlush");
    FlushGalley(prnt);
  }
  else if( kill )  DeleteNode(dest_index)
  debug0(DGF, DD, "ParentFlush returning.");
} /* end ParentFlush */
开发者ID:5432935,项目名称:crossbridge,代码行数:13,代码来源:z20.c

示例11: main

void main()
{
	cur *Cur = NULL;
	node *Node = NULL;
	InitList(&Node, &Cur);
	InsertNode(&Node, &Cur, 0, rand());
	InsertNode(&Node, &Cur, 1, rand());
	InsertNode(&Node, &Cur, 2, rand());
	DeleteNode(&Node, &Cur, 1);
	DeleteNode(&Node, &Cur, CountList(&Node, &Cur));
	DeleteNode(&Node, &Cur, 0);
 	ShowList(&Node, &Cur);
	ReleaseList(&Node, &Cur);
}
开发者ID:jianzhedeng,项目名称:DaHuaSJJG,代码行数:14,代码来源:test.c

示例12: DelItem

bool DelItem(const Item *pi, Tree *ptree){
	Pair look;
	look = SeekItem(pi,ptree);
	if(look.child==NULL)
		return false;
	if(look.parent==NULL){ //删除根项目
		DeleteNode(&ptree->root);
	}else if(look.parent->left==look.child){
		DeleteNode(&look.parent->left);
	}else
		DeleteNode(&look.parent->right);
	ptree->items--;
	return true;
}
开发者ID:BrucesJiang,项目名称:BinarySearchTree,代码行数:14,代码来源:tree.c

示例13: FreeTrace

/*
 * Free up a trace's mallocs...
 */
void FreeTrace(Trptr t)
{
if(straces)
	{
	struct strace_defer_free *sd = calloc_2(1, sizeof(struct strace_defer_free));
	sd->next = strace_defer_free_head;
	sd->defer = t;

	strace_defer_free_head = sd;
	return;
	}

if(t->vector)
      	{
      	bvptr bv;
	int i;

	bv=t->n.vec;
	for(i=0;i<bv->numregions;i++)
		{
		if(bv->vectors[i]) free_2(bv->vectors[i]);
		}
	
	if(bv->bits)
		{
		if(bv->bits->name) free_2(bv->bits->name);
		for(i=0;i<bv->nbits;i++)
			{
			DeleteNode(bv->bits->nodes[i]);
			}
		free_2(bv->bits);
		}

	if(bv->name) free_2(bv->name);
      	if(t->n.vec)free_2(t->n.vec);
      	}
	else
	{
	if(t->n.nd && t->n.nd->expansion)
		{
		DeleteNode(t->n.nd);
		}
	}

if(t->asciivalue) free_2(t->asciivalue);
if((t->is_alias)&&(t->name)) free_2(t->name);

free_2( t );
}
开发者ID:embisi-github,项目名称:embisi_gip,代码行数:52,代码来源:analyzer.c

示例14: main

int main( void )
{
  List *list = CreateList( );
  node *n;

  int x = 17;
  int y = 18;
  int z = 19;

  InsertFront( list, &x, sizeof( int ) );
  InsertFront( list, &y, sizeof( int ) );
  InsertFront( list, &z, sizeof( int ) );

  // Loop through list. It's important to use ListBegin and ListEnd for proper looping.
  // Make note of what pointers Begin and End return.
  for(n = ListBegin( list ); n != ListEnd( list ); n = n->next)
    printf( "%d\n", NODE_DATA( n, int ) );

  // Proper way to delete nodes from list is like so:
  // note -- we are not doing n = n->next within the for loop, instead
  //         we use the return value of delete
  for(n = ListBegin( list ); n != ListEnd( list );)
    n = DeleteNode( list, n );

  getchar( );

  return 0;
}
开发者ID:RandyGaul,项目名称:GAM_150_Containers,代码行数:28,代码来源:main.c

示例15: TB_SAFE_MEMFREE

// ******************************************************************
// Löscht einen Octree-Knoten rekursiv
tbResult tbOctree::DeleteNode(tbOctreeNode* pNode)
{
    // Ist es ein Endknoten? Wenn ja, werden seine Daten gelöscht.
    if(pNode->bIsLeaf)
    {
        TB_SAFE_MEMFREE(pNode->pdwEffectStart);
        TB_SAFE_MEMFREE(pNode->pdwEffectEnd);
        TB_SAFE_MEMFREE(pNode->pdwMinIndex);
        TB_SAFE_MEMFREE(pNode->pdwMaxIndex);

        if(m_bExtraData)
        {
            TB_SAFE_MEMFREE(pNode->pTrianglePlanes);
            TB_SAFE_MEMFREE(pNode->pdwIndices);
        }
    }
    else
    {
        // Die 8 untergeordneten Knoten rekursiv löschen
        for(DWORD i = 0; i < 8; i++) DeleteNode(pNode->apChild[i]);
    }

    // Den Knoten selbst löschen
    TB_SAFE_MEMFREE(pNode);

    return TB_OK;
}
开发者ID:BackupTheBerlios,项目名称:aigine,代码行数:29,代码来源:tbOctree.cpp


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