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

C++ GetDepth函数代码示例

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

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



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

示例1: main

main() {
	BiTNode * n1 = MakeNode(10, NULL, NULL);
	BiTNode * n2 = MakeNode(20, NULL, NULL);
	BiTNode * n3 = MakeNode(30, n1, n2);
	BiTNode * n4 = MakeNode(40, NULL, NULL);
	BiTNode * n5 = MakeNode(50, NULL, NULL);
	BiTNode * n6 = MakeNode(60, n4, n5);
	BiTNode * n7 = MakeNode(70, NULL, NULL);

	BiTree tree = InitBiTree(n7);
	SetLChild(tree, n3);
	SetRChild(tree, n6);

	printf("树的深度为:%d \n", GetDepth(tree));
	printTree(tree, GetDepth(tree));

	printf("\n先序遍历如下:");
	PreOrderTraverse(tree, print);

	printf("\n中序遍历如下:");
	InOrderTraverse(tree, print);

	printf("\n后序遍历如下:");
	PostOrderTraverse(tree, print);

	DeleteChild(tree, 1);
	printf("\n后序遍历如下:");
	PostOrderTraverse(tree, print);

	DestroyBiTree(tree);
	if (IsEmpty(tree))
		printf("\n二叉树为空,销毁完毕\n");
}
开发者ID:redspider110,项目名称:study_doc,代码行数:33,代码来源:test.c


示例2: GetDepth

void Label::DrawSelf()
{
	int l_posX = 0;
	int l_posY = 0;

	m_pRenderer->SetRenderMode(RM_SOLID);

	m_pRenderer->RenderFreeTypeText(m_GUIFont, (float)l_posX, (float)l_posY, GetDepth(), m_colour, 1.0f, "%s", m_text.c_str());

	if(m_outline)
	{
		m_pRenderer->RenderFreeTypeText(m_OutlineGUIFont, (float)l_posX, (float)l_posY, GetDepth(), m_outlineColour, 1.0f, "%s", m_text.c_str());
	}

	/* DEBUG : Text bounds checking
	int l_stringWidth = m_pRenderer->GetFreeTypeTextWidth(m_GUIFont, "%s", m_text.c_str());
	int l_stringHeight = m_pRenderer->GetFreeTypeTextHeight(m_GUIFont, "%s", m_text.c_str());

	int l_outlineX1 = 0;
	int l_outlineX2 = l_stringWidth;
	int l_outlineY1 = 0;
	int l_outlineY2 = l_stringHeight;

	m_pRenderer->PushMatrix();
		m_pRenderer->SetRenderMode(RM_WIREFRAME);
		m_pRenderer->EnableImmediateMode(IM_QUADS);
		m_pRenderer->ImmediateColourAlpha(1.0f, 1.0f, 1.0f, 1.0f);
		m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY1, (int)m_depth);
		m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY1, (int)m_depth);
		m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY2, (int)m_depth);
		m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY2, (int)m_depth);
		m_pRenderer->DisableImmediateMode();
	m_pRenderer->PopMatrix();
	*/
}
开发者ID:AlwaysGeeky,项目名称:Vox,代码行数:35,代码来源:label.cpp


示例3: SetPosition

/*--------------------------------------------------------------------------------*/
AudioObjectParameters& AudioObjectParameters::Modify(const Modifier& modifier, const ADMAudioObject *object)
{
  if (modifier.rotation.IsSet())
  {
    SetPosition(GetPosition() * modifier.rotation.Get());
    if (IsMinPositionSet()) SetMinPosition(GetMinPosition() * modifier.rotation.Get());
    if (IsMaxPositionSet()) SetMaxPosition(GetMaxPosition() * modifier.rotation.Get());

    Position size(GetWidth(), GetDepth(), GetHeight());
    size *= modifier.rotation.Get();
    SetWidth(static_cast<float>(size.pos.x));
    SetDepth(static_cast<float>(size.pos.y));
    SetHeight(static_cast<float>(size.pos.z));
  }
  if (modifier.position.IsSet()) SetPosition(GetPosition() + modifier.position.Get());
  if (modifier.scale.IsSet())
  {
    SetPosition(GetPosition() * modifier.scale.Get());
    if (IsMinPositionSet()) SetMinPosition(GetMinPosition() * modifier.scale.Get());
    if (IsMaxPositionSet()) SetMaxPosition(GetMaxPosition() * modifier.scale.Get());

    Position size(GetWidth(), GetDepth(), GetHeight());
    size *= modifier.scale.Get();
    SetWidth(static_cast<float>(size.pos.x));
    SetDepth(static_cast<float>(size.pos.y));
    SetHeight(static_cast<float>(size.pos.z));
  }
  if (modifier.gain.IsSet()) SetGain(GetGain() * modifier.gain.Get());

  // apply specific modifications (from derived classes)
  modifier.Modify(*this, object);

  return *this;
}
开发者ID:Dysonics,项目名称:bbcat-adm,代码行数:35,代码来源:AudioObjectParameters.cpp


示例4: GetDepth

/// 求二叉树的深度
/// 递归解法:如果二叉树为空,二叉树的深度为0
///           如果二叉树不空,二叉树的深度 = max(左子树深度,右子树深度)+1
int GetDepth(TreeNode* root)
{
	if(root == NULL) /// 递归出口
		return 0;
	int depthLeft = GetDepth(root->left);
	int depthRight = GetDepth(root->right);
	return (depthLeft > depthRight)?(depthLeft + 1):(depthRight + 1);
}
开发者ID:guker,项目名称:Algrithm-Learning,代码行数:11,代码来源:BinaryTree.cpp


示例5: while

//更新深度
void MyTree::UpdateDepth(TreeNode* pNode)
{
  TreeNode* pParent = pNode->m_pParent; 
  while(pParent)
  {
    //设置父节点的深度
    int nLeftDepth = GetDepth(pParent->m_pLeft);
    int nRightDepth = GetDepth(pParent->m_pRight);
    pParent->m_nDepth = max(nLeftDepth, nRightDepth) + 1;

    //判断是否平衡
    if(abs(nLeftDepth - nRightDepth) >= 2)
    {
      TreeNode* pNode1 = pParent;
      TreeNode* pNode2 = NULL;
      TreeNode* pNode3 = NULL;

      if(pNode1->m_pLeft)
      {
        pNode2 = pNode1->m_pLeft;
      }
      else
      {
        pNode2 = pNode1->m_pRight;
      }

      if(pNode2->m_pLeft)
      {
        pNode3 = pNode2->m_pLeft;
      }
      else
      {
        pNode3 = pNode2->m_pRight;
      }

      //进行相关的旋转操作
      if(pNode1->m_pLeft == pNode2 && pNode2->m_pLeft == pNode3)
      {
        //右单旋
      }
      else if(pNode1->m_pRight == pNode2 && pNode2->m_pRight == pNode3)
      {
        //左单旋
      }
      else if(pNode1->m_pRight == pNode2 && pNode2->m_pLeft == pNode3)
      {
        //先右单旋 再左单旋
      }
      else if(pNode1->m_pLeft == pNode2 && pNode2->m_pRight == pNode3)
      {
        //先左单旋 再右单旋
      }
    }

    pParent = pParent->m_pParent;
  }
}
开发者ID:styxschip,项目名称:Note,代码行数:58,代码来源:MyTree.cpp


示例6: GetTop

bool
nsTreeRows::iterator::operator==(const iterator& aIterator) const
{
    if (GetDepth() != aIterator.GetDepth())
        return false;

    if (GetDepth() == 0)
        return true;

    return GetTop() == aIterator.GetTop();
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:11,代码来源:nsTreeRows.cpp


示例7: GetTop

bool
nsTreeRows::iterator::operator==(const iterator& aIterator) const
{
    if (GetDepth() != aIterator.GetDepth())
        return PR_FALSE;

    if (GetDepth() == 0)
        return PR_TRUE;

    return GetTop() == aIterator.GetTop();
}
开发者ID:ehsan,项目名称:mozilla-history,代码行数:11,代码来源:nsTreeRows.cpp


示例8: wxCHECK_RET

void wxBitmap::SetPalette(const wxPalette& palette)
{
    wxCHECK_RET( IsOk(), wxT("invalid bitmap") );
    wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") );

    AllocExclusive();
    wxDELETE(M_BITMAP->m_palette);

    if ( !palette.IsOk() ) return;

    M_BITMAP->m_palette = new wxPalette(palette);
}
开发者ID:beanhome,项目名称:dev,代码行数:12,代码来源:bitmap.cpp


示例9: GetDepth

///== /////////////////////////////////////////////
int GetDepth(RBTreeNode *node)
{
  
  RBTreeNode *l = node->left;
  RBTreeNode *r = node->right;
  int ld = 0;
  int rd = 0;
  if (l != 0) ld = 1 + GetDepth(l); 
  if (r != 0) rd = 1 + GetDepth(r); 
  if (ld >= rd) return ld; else return rd;
  return 0;
}
开发者ID:tokar1,项目名称:mech-math,代码行数:13,代码来源:treeTst.cpp


示例10:

unsigned int BinarySearchTree<Key, Value>::GetDepth (typename BinarySearchTree<Key, Value>::BSTnode* subtree)
{
    unsigned int left=0, right=0, root=0;
    if (subtree==NULL)
    {
        return 0;
    }
    left=GetDepth(subtree->m_left);
    right=GetDepth(subtree->m_right);
    root=( left>right ? left : right )+1;
    return root;
}
开发者ID:Akagi201,项目名称:akcode,代码行数:12,代码来源:binary_search_tree.cpp


示例11: Parse

		void Parse()
		{
			ReadNextNode();

			WriteElement();

			int nDepth = GetDepth();
			if ( 0 == xmlTextReaderIsEmptyElement(reader) )
			{
				XmlNodeType eNodeType = XmlNodeType_None;

				int nCurDepth = -1;
				// У закрывающего тэга глубина на 1 больше, чем у открывающего
                while( true )
				{
					if ( 1 != xmlTextReaderRead(reader) )
						break;

					int nTempType = xmlTextReaderNodeType(reader);
					if(-1 == nTempType)
						break;
					eNodeType = (XmlNodeType)nTempType;

					nCurDepth = GetDepth();
					if ( eNodeType == XmlNodeType_Text || eNodeType == XmlNodeType_Whitespace || eNodeType == XmlNodeType_SIGNIFICANT_WHITESPACE )
						m_pCurrentNode->m_sText += GetText();
					else if (eNodeType == XmlNodeType_Element)
						WriteElement();
					else if (eNodeType == XmlNodeType_EndElement)
					{
						m_list.pop_back();
						
						if (0 != m_list.size())
						{
							std::list<CXmlNodeBase*>::iterator iter = m_list.end();
							--iter;
							m_pCurrentNode = *iter;
						}
						else
						{
							m_pCurrentNode = m_pNode;
						}
					}

					nCurDepth = GetDepth();
					if ( nCurDepth < nDepth )
						break;

					if ( XmlNodeType_EndElement == eNodeType && nCurDepth == nDepth )
						break;
				}
			}
		}
开发者ID:alexandervnuchkov,项目名称:core,代码行数:53,代码来源:libxml2.cpp


示例12: NS_PRECONDITION

void
nsTreeRows::iterator::Prev()
{
    NS_PRECONDITION(GetDepth() > 0, "cannot increment an uninitialized iterator");

    // Decrement the absolute row index
    --mRowIndex;

    // Move to the previous child in this subtree
    --(GetTop().mChildIndex);

    // Have we exhausted the current subtree?
    if (GetTop().mChildIndex < 0) {
        // Yep. See if we've just iterated back to the first element
        // in the tree, period. Walk back up the stack, looking for
        // any unfinished subtrees.
        PRInt32 unfinished;
        for (unfinished = GetDepth() - 2; unfinished >= 0; --unfinished) {
            const Link& link = mLink[unfinished];
            if (link.mChildIndex >= 0)
                break;
        }

        // If there are no unfinished subtrees in the stack, then this
        // iterator is exhausted. Leave it in the same state that
        // First() does.
        if (unfinished < 0)
            return;

        // Otherwise, we ran off the end of one of the inner
        // subtrees. Pop up to the next unfinished level in the stack.
        mLink.SetLength(unfinished + 1);
        return;
    }

    // Is there a child subtree immediately prior to our current
    // position? If so, descend into it, grovelling down to the
    // deepest, rightmost left edge.
    Subtree* parent = GetTop().GetParent();
    PRInt32 index = GetTop().GetChildIndex();

    Subtree* subtree = (*parent)[index].mSubtree;

    if (subtree && subtree->Count()) {
        do {
            index = subtree->Count() - 1;
            Append(subtree, index);

            parent = subtree;
            subtree = (*parent)[index].mSubtree;
        } while (subtree && subtree->Count());
    }
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:53,代码来源:nsTreeRows.cpp


示例13: CheckList

void ExperimentalPoint::CheckList(TString grid, int quad, int level){
  
  //Check if it's already in the list
  for (unsigned i = 0 ; i < flistGrid.size() ; i++)
	if(grid == flistGrid.at(i) && quad == flistQuad.at(i) && GetDepth(level) == flistDepth.at(i) ) return ;

//otherwise 
	flistGrid.push_back(grid) ;
	flistQuad.push_back(quad) ;
	flistDepth.push_back(GetDepth(level)); 

return; 
}
开发者ID:moukaddam,项目名称:LensMapper,代码行数:13,代码来源:ExperimentalPoint.cpp


示例14: GetDepth

//函数返回根结点的最大和最小深度
Depth GetDepth(SearchTree tree) {
	if (NULL == tree) {
		Depth empty = {0, 0};
		return empty;
	}

	Depth lhs = GetDepth(tree->left);
	Depth rhs = GetDepth(tree->right);
	Depth depth;
	depth.max_depth = 1 + max(lhs.max_depth, rhs.max_depth);
	depth.min_depth = 1 + min(lhs.min_depth, rhs.min_depth);
	return depth;
}
开发者ID:liyangddd,项目名称:algorithms,代码行数:14,代码来源:4tree.cpp


示例15: GetDepth

//求二叉树深度
int GetDepth( BiNode *T )
{
	if( T == NULL )
	{
	      	return 0;
	}

	// int Left_Length = GetDepth( T->lch );
	// int Right_Length = GetDepth( T->rch );
	// return Left_length > Right_Length ?( Left_Length + 1 ) : ( Right_length + 1 );
	return GetDepth( T->lch ) > GetDepth( T->rch ) ?
		( GetDepth( T->lch ) + 1 ) : ( GetDepth( T->rch ) + 1 );
}
开发者ID:Crabbit,项目名称:c,代码行数:14,代码来源:creat_btree.c


示例16: GetWidth

void Terrain::BuildQuadPatchVB(ID3D11Device* device)
{
	patchVertices.resize(mNumPatchVertRows*mNumPatchVertCols);

	float halfWidth = 0.5f*GetWidth();
	float halfDepth = 0.5f*GetDepth();

	float patchWidth = GetWidth() / (mNumPatchVertCols-1);
	float patchDepth = GetDepth() / (mNumPatchVertRows-1);
	float du = 1.0f / (mNumPatchVertCols-1);
	float dv = 1.0f / (mNumPatchVertRows-1);

	for(UINT i = 0; i < mNumPatchVertRows; ++i)
	{
		float z = halfDepth - i*patchDepth;
		for(UINT j = 0; j < mNumPatchVertCols; ++j)
		{
			float x = -halfWidth + j*patchWidth;

			patchVertices[i*mNumPatchVertCols+j].Pos = XMFLOAT3(x, 0.0f, z);

			// Stretch texture over grid.
			patchVertices[i*mNumPatchVertCols+j].Tex.x = j*du;
			patchVertices[i*mNumPatchVertCols+j].Tex.y = i*dv;
		}
	}

	// Store axis-aligned bounding box y-bounds in upper-left patch corner.
	for(UINT i = 0; i < mNumPatchVertRows-1; ++i)
	{
		for(UINT j = 0; j < mNumPatchVertCols-1; ++j)
		{
			UINT patchID = i*(mNumPatchVertCols-1)+j;
			patchVertices[i*mNumPatchVertCols+j].BoundsY = mPatchBoundsY[patchID];
		}
	}

    D3D11_BUFFER_DESC vbd;
    vbd.Usage = D3D11_USAGE_IMMUTABLE;
	vbd.ByteWidth = sizeof(Vertex::Terrain) * patchVertices.size();
    vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    vbd.CPUAccessFlags = 0;
    vbd.MiscFlags = 0;
	vbd.StructureByteStride = 0;

	D3D11_SUBRESOURCE_DATA vinitData;
    vinitData.pSysMem = &patchVertices[0];
    HR(device->CreateBuffer(&vbd, &vinitData, &mQuadPatchVB));
}
开发者ID:evzaitsev,项目名称:3D-FPS-Game,代码行数:49,代码来源:Terrain.cpp


示例17: max

//右单旋
void MyTree::RightRotate(TreeNode* pNode1, TreeNode* pNode2)
{
  /*
             [X]              X
          [N1]   C         N2    C
       [N2]    B         N3   N1
    N3   [A]                A    B
  */
  TreeNode* pNodeX = pNode1->m_pParent;
  TreeNode* pNodeA = pNode2->m_pRight;

  //pNodeX
  if(pNodeX)
  {
    if(pNodeX->m_pLeft == pNode1)
    {
      pNodeX->m_pLeft = pNode2;
    }
    else
    {
      pNodeX->m_pRight = pNode2;
    }
  }
  else
  {
    m_pRoot = pNode2;
  } 

  //pNode1
  pNode1->m_pLeft = pNodeA;
  pNode1->m_pParent = pNode2;

  //pNode2
  pNode2->m_pParent = pNodeX;
  pNode2->m_pRight = pNode1;

  //pNodeA
  if(pNodeA)
  {
    pNodeA->m_pParent = pNode1;
  }

  //更新pNode1和pNode2的深度
  pNode1->m_nDepth = max(GetDepth(pNode1->m_pLeft),
    GetDepth(pNode1->m_pRight)) + 1;
  pNode2->m_nDepth = max(GetDepth(pNode2->m_pLeft),
    GetDepth(pNode2->m_pRight)) + 1;
}
开发者ID:styxschip,项目名称:Note,代码行数:49,代码来源:MyTree.cpp


示例18: while

bool SUIComponentComposite::PostDraw()
{
	SPComposite::ChildIterator iter = children.begin();

	while(iter != children.end())
	{
		if (*iter)
		{
			(*iter)->SetRenderTarget(NULL);
			iter++;
		}
		else
		{
			iter = children.erase(iter);
		}
	}

	if (childTarget)
	{
		SPSpriteManager::GetSingleton().RenderWithRotation(
			childTarget, 
			GetCurrentEffect(), 
			D3DXVECTOR3(GetPosition().x, GetPosition().y, GetDepth()),
			properties.rotationCenter,
			properties.rotation,
			properties.transparency * SPColor::White,
			renderTarget);
	}	

	//childTarget = NULL;

	return true;
}
开发者ID:weimingtom,项目名称:spengine-1,代码行数:33,代码来源:SUIComponentComposite.cpp


示例19: GetPosition

void AudioObjectParameters::MultiplyByScene(float width, float height, float depth)
{
  Position pos = GetPosition().Cart();
  pos.pos.x *= width;
  pos.pos.y *= depth;
  pos.pos.z *= height;
  SetPosition(GetPosition().polar ? pos.Polar() : pos);

  if (IsMinPositionSet())
  {
    Position pos = GetMinPosition().Cart();
    pos.pos.x *= width;
    pos.pos.y *= depth;
    pos.pos.z *= height;
    SetMinPosition(GetMinPosition().polar ? pos.Polar() : pos);
  }

  if (IsMaxPositionSet())
  {
    Position pos = GetMaxPosition().Cart();
    pos.pos.x *= width;
    pos.pos.y *= depth;
    pos.pos.z *= height;
    SetMaxPosition(GetMaxPosition().polar ? pos.Polar() : pos);
  }

  SetWidth(GetWidth() * width);
  SetHeight(GetHeight() * height);
  SetDepth(GetDepth() * depth);

  if (excludedZones) excludedZones->MultiplyByScene(width, height, depth);
}
开发者ID:Dysonics,项目名称:bbcat-adm,代码行数:32,代码来源:AudioObjectParameters.cpp


示例20: GetWidth

float Box::GetVolume() const
{
    float w = GetWidth();
    float h = GetHeight();
    float d = GetDepth();
    return w * h * d;
}
开发者ID:sephirot47,项目名称:Bang,代码行数:7,代码来源:Box.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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