示例#1
0
   ARV_tpCondRet ARV_InserirDireita( void* pArvoreParm, void* ListaCharParm )
   {
      tpArvore * pArvore ;

      ARV_tpCondRet CondRet ;

      tpNoArvore * pCorr ;
      tpNoArvore * pNo ;

      if ( pArvoreParm == NULL )
      {
         return ARV_CondRetArvoreNaoExiste ;
      } 

      pArvore = ( tpArvore* )( pArvoreParm );

      /* Tratar vazio, direita */

         CondRet = CriarNoRaiz( pArvore, ListaCharParm ) ;
         if ( CondRet != ARV_CondRetNaoCriouRaiz )
         {
            return CondRet ;
         } /* if */

      /* Criar nó à direita de folha */

         pCorr = pArvore->pNoCorr ;
         if ( pCorr == NULL )
         {
            return ARV_CondRetErroEstrutura ;
         } /* if */

         if ( pCorr->pNoDir == NULL )
         {
            pNo = CriarNo( pArvore, ListaCharParm ) ;
            if ( pNo == NULL )
            {
               return ARV_CondRetFaltouMemoria ;
            } /* if */
            pNo->pNoPai      = pCorr ;
            pCorr->pNoDir    = pNo ;
            pArvore->pNoCorr = pNo ;

            return ARV_CondRetOK ;
         } /* if */

      /* Tratar não folha à direita */

         return ARV_CondRetNaoEhFolha ;

   } /* Fim função: ARV Adicionar filho à direita */
示例#2
0
   ARV_tpCondRet ARV_InserirDireita( char ValorParm )
   {

      ARV_tpCondRet CondRet ;

      tpNoArvore * pCorr ;
      tpNoArvore * pNo ;

      /* Tratar vazio, direita */

         CondRet = CriarNoRaiz( ValorParm ) ;
         if ( CondRet != ARV_CondRetNaoCriouRaiz )
         {
            return CondRet ;
         } /* if */

      /* Criar nó à direita de folha */

         pCorr = pArvore->pNoCorr ;
         if ( pCorr == NULL )
         {
            return ARV_CondRetErroEstrutura ;
         } /* if */

         if ( pCorr->pNoDir == NULL )
         {
            pNo = CriarNo( ValorParm ) ;
            if ( pNo == NULL )
            {
               return ARV_CondRetFaltouMemoria ;
            } /* if */
            pNo->pNoPai      = pCorr ;
            pCorr->pNoDir    = pNo ;
            pArvore->pNoCorr = pNo ;

            return ARV_CondRetOK ;
         } /* if */

      /* Tratar não folha à direita */

         return ARV_CondRetNaoEhFolha ;

   } /* Fim função: ARV Adicionar filho à direita */
示例#3
0
MAT_tpCondRet MAT_CriarMatriz( MAT_tppMatriz *tpMat, GRA_tppGrafo pGrafo , int numElementos){
	   
		MAT_tpCondRet CondRet ;

		MAT_tppMatriz mMatriz ;
		
		mMatriz = ( MAT_tppMatriz ) malloc ( sizeof ( MAT_tpMatriz ) );
			/* Malloc para gerar um ponteiro de matriz */

		   
	   if(mMatriz == NULL)
	   {
		   return MAT_CondRetFaltouMemoria ;
	   } /* if */
	   
	   mMatriz->pNoCorr      = NULL;
	   mMatriz->pNoRaiz      = NULL;
	   mMatriz->pNoIndLinha  = NULL;

	   CondRet = CriarNoRaiz(mMatriz, pGrafo , numElementos);
			 /* Inicializo a estrutura da matriz setando a raiz */

	   if(CondRet != MAT_CondRetOK)
	   {
		return CondRet;
	   } /* if */


	   (*tpMat) = ( MAT_tpMatriz* ) malloc( sizeof( MAT_tppMatriz )) ;

		if ( (*tpMat) == NULL )
		{
			return MAT_CondRetFaltouMemoria ;
		} /* if */

		(*tpMat) = mMatriz ;


		return MAT_CondRetOK ;
}