示例#1
0
void TreeStageNode::sortChildren(int startIndex, int lastIndex)
{
	if (startIndex == lastIndex)
		return;
	std::vector<TreeStageNode *>::iterator begin, end;
	begin = m_cildren.begin() + startIndex;
	end = m_cildren.begin() + lastIndex;
	std::sort(begin, end, CompareNodes());
}
示例#2
0
文件: Tree.cpp 项目: cherry-wb/GALex
		// Compare topologies of the two subtrees and data they contains
		bool GaTreeBase::CompareNodes(const GaTreeNodeBase* n1,
			const GaTreeNodeBase* n2) const
		{
			// if two nods has different number of children, their topologies are different
			if( *n1 != *n2 || n1->GetChildren()->GetCount() != n2->GetChildren()->GetCount() )
				return false;

			// compare topologies of all children's subtrees and data they contain
			for( const GaListNode<GaTreeNodeBase*> *c1 = n1->GetChildren()->GetHead(), *c2 = n2->GetChildren()->GetHead(); c1 ; c1 = c1->GetNext(), c2 = c2->GetNext() )
			{
				if( !CompareNodes( c1->GetValue(), c2->GetValue() ) )
					return false;
			}

			return true;
		}
示例#3
0
bool CEntityPoolSignature::CompareSignature(const CEntityPoolSignature& otherSignature) const
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);
	LOADING_TIME_PROFILE_SECTION(GetISystem());

	bool bResult = false;

	if (m_bGenerated)
	{
		// Perform quick test first
		//if (m_uTestMask == otherSignature.m_uTestMask)
		{
			// Perform in-depth test using serialization objects
			bResult = CompareNodes(m_Signature, otherSignature.m_Signature);
		}
	}

	return bResult;
}
示例#4
0
bool CEntityPoolSignature::CompareNodes(const XmlNodeRef &a, const XmlNodeRef &b, bool bRecursive)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);

	assert(bool(a));
	assert(bool(b));

	bool bResult = (a && b && a->isTag(b->getTag()));

	// Check value
	bResult &= (bResult && 0 == strcmp(a->getContent(), b->getContent()));

	// Check attributes
	bResult &= (bResult && CompareNodeAttributes(a, b));

	// Check children if recursive
	if (bResult && bRecursive)
	{
		const int childCount_a = a->getChildCount();
		const int childCount_b = b->getChildCount();
		bResult &= (childCount_a == childCount_b);

		if (bResult)
		{
			for (int child = 0; bResult && child < childCount_a; ++child)
			{
				XmlNodeRef child_a = a->getChild(child);
				XmlNodeRef child_b = b->getChild(child);
				if (child_a && child_b)
				{
					bResult &= CompareNodes(child_a, child_b, true);
				}
			}
		}
	}

	return bResult;
}