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


C++ set_parent函数代码示例

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


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

示例1: check_and_rorate

AVL*  check_and_rorate(AVL * rnode, AVL* parent) {
	AVL * rret = rnode;
	if (rnode == NULL)
		return;
	if (rnode->height >= 2) { 
		//left tree height than right
		if(rnode->lchild != NULL 
			&& rnode->lchild->lchild != NULL) {
			rret = LL_Rotate(rnode);
		} else if(rnode->lchild != NULL 
			&& rnode->lchild->rchild != NULL) {
			rret = LR_Rotate(rnode);
		}

		if (parent != NULL) {
			set_parent(rret, rnode, parent);
		}
		
	} else if (rnode->height <= -2) {
		//right tree height than left
		if (rnode->rchild != NULL 
			&& rnode->rchild->rchild != NULL) {
			rret = RR_Rotate(rnode);
		} else if (rnode->rchild != NULL
			&& rnode->rchild->lchild != NULL) {
			rret = RL_Rotate(rnode);
		}
		if (parent != NULL) {
			set_parent(rret, rnode, parent);
		}
	}
	return rret;
}
开发者ID:Davidlx,项目名称:Learn-Algorithm,代码行数:33,代码来源:avl_tree.c

示例2: rbtree_rotate

void
rbtree_rotate(rbtree_t      *tree,
              rbtree_node_t *node,
              int           left)
{
  rbtree_node_t *tmp    = node->child[left];
  rbtree_node_t *parent = get_parent(node);

  node->child[left] = tmp->child[!left];
  if(tmp->child[!left] != NULL)
    set_parent(tmp->child[!left], node);

  tmp->child[!left] = node;
  set_parent(tmp, parent);
  if(parent != NULL)
  {
    if(node == parent->child[!left])
      parent->child[!left] = tmp;
    else
      parent->child[left] = tmp;
  }
  else
    tree->root = tmp;
  set_parent(node, tmp);
}
开发者ID:Almamu,项目名称:ctrulib,代码行数:25,代码来源:rbtree_rotate.c

示例3: rotate_left

static void rotate_left(struct rbtree_node* node,struct rbtree* tree)
{
    struct rbtree_node* p = node;
    struct rbtree_node* q = node->right;
    struct rbtree_node* parent = node->parent;
    if(parent == NULL)
    {
        tree->root = q;
    }
    else
    {
        if(parent->left == p)
            parent->left = q;
        else
            parent->right = q;
    }
    set_parent(parent,q);
    set_parent(q,p);

    p->right = q->left;
    if(q->left)
        set_parent(p,q->left);
    q->left = p;

}
开发者ID:SylvanHuang,项目名称:rbtree,代码行数:25,代码来源:rbtree.c

示例4: rotate_right

static void rotate_right(struct FwAvlNode* node, struct FwAvlTree* tree)
{
    struct FwAvlNode* p = node;
    struct FwAvlNode* q = node->left;
    struct FwAvlNode* parent = get_parent(node);

    if(!is_root(p))
    {
        if(parent->left == p)
            parent->left = q;
        else
            parent->right = q;
    }
    else
    {
        tree->root = q;
    }

    set_parent(parent, q);
    set_parent(q, p);

    p->left = q->right;
    if(p->left != NULL)
    {
        set_parent(p, p->left);
    }
    q->right = p;
}
开发者ID:BMNLabs,项目名称:snort,代码行数:28,代码来源:fw_avltree.c

示例5: Board

	Board(Board *b) 
	{
	
		//  Allocate board memory
		board.resize(BOARD_SIZE);
		for (int i = 0; i < BOARD_SIZE; ++i) {
			for (int j = 0; j < BOARD_SIZE; ++j) {
				board[i].push_back(NULL);
			}
		}
		
		//  Initialize board to match argument board.
		for (int i = 0; i < BOARD_SIZE; ++i) {
			for (int j = 0; j < BOARD_SIZE; ++j) {
				set_piece(i, j, b->get_piece(i, j));
			}
		}
		
		//  Set parent board.
		set_parent(b);
		
		//  Set player move of current board.
		turn = !b->get_player();
			
	}
开发者ID:adityachivu,项目名称:personal,代码行数:25,代码来源:game_board.hpp

示例6: set_parent

/** Recursively cycles through all the left and right children setting their node_parent as the TreeNode before
 @param child is a pointer to the TreeNode object being cycled through and having each parent TreeNode set
 */
void BinarySearchTree::set_parent(TreeNode* child) {
    //if TreeNode pointer is nullptr, then cannot continue to set node_parent in that direction
    if(child == nullptr) {
        return;
    }
    //if left child is not nullptr, continue in the left direction
    if(child->left != nullptr) {
        child->left->node_parent = child;
        set_parent(child->left);
    }
    //if right child is not nullptr, continue in the right direction
    if(child->right != nullptr) {
        child->right->node_parent = child;
        set_parent(child->right);
    }
}
开发者ID:KendrickQChu,项目名称:PIC10C_Hw6,代码行数:19,代码来源:BinarySearchTree.cpp

示例7: mu_container_append_siblings

MuContainer*
mu_container_append_siblings (MuContainer *c, MuContainer *sibling)
{
	g_assert (c);

	g_return_val_if_fail (c, NULL);
	g_return_val_if_fail (sibling, NULL);
	g_return_val_if_fail (c != sibling, NULL);

	/* assert_no_duplicates (c); */

	set_parent (sibling, c->parent);

	/* find the last sibling and append; first we try our cache
	 * 'last', otherwise we need to walk the chain. We use a
	 * cached last as to avoid walking the chain (which is
	 * O(n*n)) */
	if (c->last)
		c->last->next = sibling;
	else {
		/* no 'last' cached, so walk the chain */
		MuContainer *c2;
		for (c2 = c; c2 && c2->next; c2 = c2->next);
		c2->next = sibling;
	}
	/* update the cached last */
	c->last = sibling->last ? sibling->last : sibling;

	/* assert_no_duplicates (c); */

	return c;
}
开发者ID:DamienCassou,项目名称:mu,代码行数:32,代码来源:mu-container.c

示例8: set_parent

void
SgAsmPERVASizePair::ctor(SgAsmPERVASizePairList *parent, rose_addr_t rva, rose_addr_t size)
{
    p_e_rva = rva;
    p_e_size = size;
    set_parent(parent);
}
开发者ID:matzke1,项目名称:rose-develop,代码行数:7,代码来源:PeRvaSizePair.C

示例9: UG_ASSERT

void MultiGrid::element_created(TElem* elem, TParent* pParent,
								TElem* pReplaceMe)
{
	UG_ASSERT(pReplaceMe, "Only call this method with a valid element which shall be replaced.");
	int level = get_level(pReplaceMe);

//	register parent and child
	set_parent(elem, pParent);

	if(pParent)
	{
	//	add the element to the parents children list
	//	pParent should have an info object at this time!
		typename mginfo_traits<TParent>::info_type& parentInfo = get_info(pParent);
		parentInfo.replace_child(elem, pReplaceMe);
	}

//	put the element into the hierarchy
	level_required(level);
	m_hierarchy.assign_subset(elem, level);

//	explicitly copy the parent-type from pReplaceMe to the new vrt.
//	This has to be done explicitly since a parent may not exist locally in
//	a parallel environment.
	set_parent_type(elem, parent_type(pReplaceMe));
}
开发者ID:stephanmg,项目名称:ugcore,代码行数:26,代码来源:multi_grid_impl.hpp

示例10: get_level

void MultiGrid::element_created(TElem* elem, TParent* pParent)
{
//	if hierarchical_insertion is enabled, the element will be put
//	into the next higher level of pParents level.

	int level = 0;
	if(pParent)
	{
	//	the element is inserted into a new layer.
		level = get_level(pParent) + 1;
		set_parent_type(elem, pParent->base_object_id());
	}
	else
		set_parent_type(elem, -1);

//	register parent and child
	//typename mginfo_traits<TElem>::info_type& info = get_info(elem);
	//info.m_pParent = pParent;
	set_parent(elem, pParent);
	if(pParent)
	{
	//	make sure that the parent has an info object
		create_child_info(pParent);

	//	add the element to the parents children list
		typename mginfo_traits<TParent>::info_type& parentInfo = get_info(pParent);
		parentInfo.add_child(elem);
	}

//	put the element into the hierarchy
	level_required(level);
	m_hierarchy.assign_subset(elem, level);
}
开发者ID:stephanmg,项目名称:ugcore,代码行数:33,代码来源:multi_grid_impl.hpp

示例11: get_parent_child

Sobby::Config::ParentEntry& Sobby::Config::ParentEntry::
	operator[](const Glib::ustring& name)
{
	ParentEntry* entry = get_parent_child(name);
	if(entry != NULL) return *entry;
	return set_parent(name);
}
开发者ID:gobby,项目名称:sobby,代码行数:7,代码来源:config.cpp

示例12: set_parent

// Set up the gadget and registers it with the UI window
//
void UI_GADGET::base_create(UI_WINDOW *wnd, int _kind, int _x, int _y, int _w, int _h)
{
	int i;

	// initialize data with passed values
	kind = _kind;
	x = _x;
	y = _y;
	w = _w;
	h = _h;

	// set up reference to UI window and initialize as having no family
	my_wnd = wnd;
	parent = NULL;
	children = NULL;
	next = prev = this;

	// this actually links the gadget into the UI window's top level family (as the youngest gadget)
	set_parent(NULL);

	// initialize variables
	hotkey = -1;
	user_function = NULL;
	disabled_flag = 0;
	base_dragging = 0;
	base_drag_x = base_drag_y = 0;
	hotspot_num = -1;
	hidden = 0;
	linked_to_hotspot = 0;
	uses_bmaps = 0;
	m_num_frames = 0;
	for ( i=0; i<MAX_BMAPS_PER_GADGET; i++ ) {
		bmap_ids[i] = -1;
	}
}
开发者ID:derek-yeung,项目名称:fs2open.github.com,代码行数:37,代码来源:gadget.cpp

示例13: ROSE_ASSERT

/** Non-parsing constructor */
void
SgAsmElfEHFrameEntryFD::ctor(SgAsmElfEHFrameEntryCI *cie)
{
    ROSE_ASSERT(cie->get_fd_entries()!=NULL);
    cie->get_fd_entries()->get_entries().push_back(this);
    ROSE_ASSERT(cie->get_fd_entries()->get_entries().size()>0);
    set_parent(cie->get_fd_entries());
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:9,代码来源:ElfErrorFrame.C

示例14: Table

LocalContext::LocalContext(Table *parent, Function *f) 
  : Table(parent,SREL,0),m_function(f), m_no_auto_dtor(false)
{
    m_type = FUNCTION;
    set_mem_unit(4);     // we work in DWORDS
    set_dword_align(4);  // *fix 1.2.3 Local contexts have 32-bit alignment _explicitly_
    set_parent(parent);
}
开发者ID:Artorios,项目名称:rootkit.com,代码行数:8,代码来源:function.cpp

示例15: default_initialization

J_PXC_Color_Stream_Processor::J_PXC_Color_Stream_Processor(J_PXC_Stream_Shared_t i_stream){
#ifndef VS_2013
	default_initialization();
#endif //!VS_2013
	M_width = i_stream->width();
	M_height = i_stream->height();
	set_parent(i_stream);
}
开发者ID:JDRiley,项目名称:J_Camera_Socket_Interface,代码行数:8,代码来源:J_PXC_Color_Stream_Processor.cpp


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