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

C++ set_parent函数代码示例

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

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



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


示例16: sys_fork

/*
  Duplicates the currently running process
  The two copies are identical except for the child having a new pid
*/
int
sys_fork(struct trapframe *tf, int32_t *retval) {

  // Prevent interrupts so address space doesn't change before getting
  // copied
  int spl = splhigh();

  // Store trapframe on the heap for copying to child
  // thread later
  struct trapframe *child_tf;
  child_tf = kmalloc(sizeof(tf));
  if (child_tf == NULL) {
    splx(spl);
    return ENOMEM;
  }

  //memcpy(child_tf, tf, sizeof(tf));
  child_tf = tf;

  // Copy parent address space
  struct addrspace *original_as;
  struct addrspace *new_as;
  original_as = curproc_getas();
  int result = as_copy(original_as, &new_as);
  if (result) {
    splx(spl);
    return ENOMEM;
  }

  // Create new process
  struct proc *new_proc = proc_create(curproc->p_name);

  // Copy process fdlist
  for (int i = 0; i < __OPEN_MAX; i++) {
    if (curproc->p_fdlist[i] != NULL) {
      new_proc->p_fdlist[i] = curproc->p_fdlist[i];
      // Increment reference count
      new_proc->p_fdlist[i]->fd_vfile->vn_refcount++;
    }
  }

  //Child process needs to have parent pid attached to it
  set_parent(curproc->pid, new_proc->pid);

  // Fork new thread, attach to new proc
  result = thread_fork("Child process", new_proc, enter_forked_process, (void *)child_tf, (unsigned long)new_as);
  if (result) {
    kfree(child_tf);
    splx(spl);
    return result;  // Error code will be returned from thread_fork
  }

  // Set retval to child process pid
  *retval = new_proc->pid;
  splx(spl);
  return 0;
}
开发者ID:HeliWang,项目名称:cs350OS,代码行数:61,代码来源:fork_syscalls.c


示例17: new_particle_system

ParticleSystemID Stage::new_particle_system_with_parent_from_file(ActorID parent, const unicode& filename, bool destroy_on_completion) {
    ParticleSystemID new_id = new_particle_system();

    auto ps = particle_system(new_id);
    ps->set_parent(parent);
    ps->set_destroy_on_completion(destroy_on_completion);

    window->loader_for(filename)->into(ps);

    return new_id;
}
开发者ID:aonorin,项目名称:KGLT,代码行数:11,代码来源:stage.cpp


示例18: m_array

inline StringIndex::StringIndex(ref_type ref, ArrayParent* parent, size_t ndx_in_parent,
                                ColumnBase* target_column,
                                bool deny_duplicate_values, Allocator& alloc):
    m_array(new Array(alloc)),
    m_target_column(target_column),
    m_deny_duplicate_values(deny_duplicate_values)
{
    REALM_ASSERT_EX(Array::get_context_flag_from_header(alloc.translate(ref)), ref, size_t(alloc.translate(ref)));
    m_array->init_from_ref(ref);
    set_parent(parent, ndx_in_parent);
}
开发者ID:0atme0,项目名称:tutu1,代码行数:11,代码来源:index_string.hpp


示例19: ROSE_ASSERT

/** Constructor adds the new note to the list of notes for the note section. */
void
SgAsmElfNoteEntry::ctor(SgAsmElfNoteSection *section)
{
    ROSE_ASSERT(section->get_entries()!=NULL);
    section->get_entries()->get_entries().push_back(this);
    ROSE_ASSERT(section->get_entries()->get_entries().size()>0);
    set_parent(section->get_entries());

    p_name = new SgAsmBasicString("");
    p_name->set_parent(this);
}
开发者ID:KurSh,项目名称:rose,代码行数:12,代码来源:ElfNote.C


示例20: set_data

bin_tree_node<Item>& bin_tree_node<Item>::operator=(bin_tree_node<Item>& rhs)
{
	if(&rhs == this)
		return *this;

	set_data(rhs.get_data());
	set_lchild(DsNULL);
	set_rchild(DsNULL);
	set_parent(DsNULL);
	
	return *this;
};
开发者ID:fezhang,项目名称:algorithms,代码行数:12,代码来源:tree.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ set_path函数代码示例发布时间:2022-05-30
下一篇:
C++ set_params函数代码示例发布时间: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