示例#1
0
CL_DomElement CL_DomElement::get_next_sibling_element() const
{
	CL_DomNode node = get_next_sibling();
	while (!node.is_null() && !node.is_element())
		node = node.get_next_sibling();
	return node.to_element();
}
示例#2
0
ListViewItem ListViewItem::remove()
{
	ListViewItem prev = get_prev_sibling();
	ListViewItem next = get_next_sibling();
	ListViewItem parent = get_parent();
	
	if (prev.is_item())
	{
		prev.impl->next_sibling = next.impl;

		if (next.is_item())
			next.impl->prev_sibling = prev.impl;
		else // no next item, update last_child of parent to point at prev.impl
			parent.impl->last_child = prev.impl;
	}
	else if (prev.is_null())
	{
		// delete first item by settin parents first item to next.impl
		parent.impl->first_child = next.impl;
	
		if (!next.is_null())
		{
			next.impl->prev_sibling = std::shared_ptr<ListViewItem_Impl>();
		}

		if (parent.impl->first_child)
		{
			if (!parent.impl->first_child->next_sibling)
				parent.impl->last_child = parent.impl->first_child;
		}
		else
		{
			// first_child = last_child = 0
			parent.impl->last_child = parent.impl->first_child;
		}
	}

	ListViewItem document_item = get_document_item();

	if (!document_item.impl->func_item_deleted.is_null())
		document_item.impl->func_item_deleted.invoke(*this);
	
	return *this;
}
示例#3
0
文件: fp_tree.cpp 项目: CCJY/engine-1
fp_item* fp_tree::merge_items(fp_item* left_item, fp_item* right_item)
{
	// merge all nodes within the tree representing the both items
	// w.r.t. left_item < right_item
	fp_node* left_node =  left_item->get_first_node();
	fp_node* right_node =  right_item->get_first_node();

	while(left_node != NULL)
	{
		// left node_next_backup
		fp_node* left_node_next_backup = left_node->get_next_item_neighbor();

		fp_node* right_node = get_next_sibling(left_node);
		if (right_node == NULL)
		{
			// no neighbor - simple interval adaption
			left_node->set_max(right_item->get_max());
		} else {
			// drop right node from parents child list
			// has to be done before the merge (because this will delete the right node)
			if (right_node->get_parent() != NULL){
				right_node->get_parent()->remove_child(right_node);
			} else {
				fp_nodelist::iterator it = find(
						m_root_nodes.begin(),
						m_root_nodes.end(),
						right_node);
				if (it != m_root_nodes.end())
					m_root_nodes.erase(it);
			}

			if (right_item->get_first_node() == right_node)
				right_item->set_first_node( right_node->get_next_item_neighbor() );

			// we have to merge the two nodes and all children
			left_node->merge(right_node);
		}

		left_node = left_node_next_backup;
	}

	right_node =  right_item->get_first_node(); // first node could be updated by the merge before

	// check eventually forgotten nodes and adapt the interval
	while (right_node != NULL)
	{
		// left node_next_backup
		fp_node* right_node_next_backup = right_node->get_next_item_neighbor();

		if ( right_node->get_min() > left_item->get_min() )
		{
			// not merged -> adapt interval, move item to left_item_list
			right_node->set_min(left_item->get_min());

			// insert right node to the front of the item neighbor list
			fp_node* first_node = left_item->get_first_node();
			first_node->set_prev_item_neighbor(right_node);

			right_node->set_next_item_neighbor(first_node);
			right_node->set_prev_item_neighbor(NULL);

			m_item_dir->set_first_node(left_item, right_node);
		}

		right_node = right_node_next_backup;
	}

	// merge items within inside the directory
	m_item_dir->merge_items(left_item, right_item);

	// remove right item from the item directory


	return left_item;
}