예제 #1
0
	/* Desencadeia à direita */
	if ( pElem->pProx != NULL )
	{
		pElem->pProx->pAnt = pElem->pAnt ;
	} 
	else
	{
		pLista->pFimLista = pElem->pAnt ;
	} /* if */
	free(pElem) ;
	pLista->numElem--;
	return ;
} /* Fim função: LIS  &Excluir elemento */
void LIS_InserirElementoApos( LIS_tppLista pLista , void * pValor)
{
      tpElemLista * pElem ;
      /* Criar elemento a inerir após */

         pElem = CriarElemento( pLista , pValor ) ;

      /* Encadear o elemento após o elemento */

         if ( pLista->pElemCorr == NULL )
         {
            pLista->pOrigemLista = pElem ;
            pLista->pFimLista = pElem ;
         } else
         {
            if ( pLista->pElemCorr->pProx != NULL )
            {
               pElem->pProx  = pLista->pElemCorr->pProx ;
               pLista->pElemCorr->pProx->pAnt = pElem ;
            } else
            {
               pLista->pFimLista = pElem ;
            } /* if */

            pElem->pAnt = pLista->pElemCorr ;
            pLista->pElemCorr->pProx = pElem ;

         } /* if */  
         pLista->pElemCorr = pElem ;  
         return;

   } /* Fim função: LIS  &Inserir elemento após */
예제 #2
0
LIS_tpCondRet LIS_InserirElementoOrdenado( LIS_tppLista pLista ,
        void *pValor,
        int (*pComp) (void *a, void *b))
{
    LIS_tpElemLista *pElem ;

#ifdef _DEBUG
    assert( pLista != NULL ) ;
#endif

    /* Criar elemento a inserir antes */
    pElem = CriarElemento( pLista , pValor ) ;
    if ( pElem == NULL )
    {
        return LIS_CondRetFaltouMemoria ;
    } /* if */
    /* Ir para o comeco da lista */
    IrInicioLista (pLista);
    /* Percorrer a lista até encontrar um valor superior ou igual */
    while (LIS_AvancarElementoCorrente(pLista, 1) != LIS_CondRetFimLista)
    {
        if (pComp(LIS_ObterValor(pLista), pValor) > 0)
        {
            break ;
        } /* if */
    } /* while */
    /* Encadear o elemento antes do elemento superior */
    return LIS_InserirElementoAntes(pLista, pValor);

} /* Fim funcao: LIS  &Inserir elemento antes */
예제 #3
0
LIS_tpCondRet LIS_InserirElementoApos ( LIS_tppLista pLista, void * pConteudo )
{

	tpElemLista * pElem;

	/* Tratar lista inexistente */

	if ( pLista == NULL ) 
	{
		return LIS_CondRetListaInexistente;
	} /* if */ 
	
	/* fim ativa: Tratar lista inexistente */

	/* Criar elemento a inserir após */

	pElem = CriarElemento( pConteudo );
	if ( pElem == NULL )
	{
		return LIS_CondRetFaltouMemoria;
	} /* if */

	/* fim ativa: Criar elemento a inserir após */

	/* Encadear o elemento após o elemento corrente */

	/* Tratar lista vazia */

	if ( pLista->pElemCorr == NULL )
	{
		pLista->pOrigemLista = pElem ;
        pLista->pFimLista = pElem ;
	} /* fim ativa: Tratar lista vazia */
	else
	{

		if ( pLista->pElemCorr->pProx != NULL )
        {
			pElem->pProx  = pLista->pElemCorr->pProx ;
            pLista->pElemCorr->pProx->pAnt = pElem ;
		} 
		else
        {
			pLista->pFimLista = pElem ;
		} /* if */

        pElem->pAnt = pLista->pElemCorr ;
        pLista->pElemCorr->pProx = pElem ;
	} /* if */ 

	pLista->numElem++;

	pLista->pElemCorr = pElem;

	/* fim ativa: Encadear o elemento após o elemento corrente */

	return LIS_CondRetOK;

} /* Fim função: LIS  &Inserir elemento após */
예제 #4
0
LST_tpCondRet LST_InserirNoApos( TpLista * pLista , void * informacao 
#ifdef _DEBUG
	, char tipoElemento
#endif
	)
{

	TpNoLista * pElem ;

	if ( pLista == NULL)
	{
		return LST_CondRetListaInexistente;
	} /* if */

	/* Criar elemento a inerir após */

	pElem = CriarElemento( pLista , informacao 
#ifdef _DEBUG
		, tipoElemento
#endif
		) ;
	if ( pElem == NULL )
	{
		return LST_CondRetFaltouMemoria ;
	} /* if */

	/* Encadear o elemento após o elemento */

	/*Se a lista está vazia */
	if ( pLista->pNoCorrente == NULL )
	{
		pLista->pOrigemLista = pElem ;
		pLista->pFimLista = pElem ;
	} else
	{
		/* Se o nó corrente é o nó fim */
		if ( pLista->pNoCorrente->pProx != NULL )
		{
			pElem->pProx  = pLista->pNoCorrente->pProx ;
			pLista->pNoCorrente->pProx->pAnt = pElem ;
		} else
		{
			pLista->pFimLista = pElem ;
		} /* if */

		pElem->pAnt = pLista->pNoCorrente ;
		pLista->pNoCorrente->pProx = pElem ;

	} /* if */

	pLista->pNoCorrente = pElem ;

	return LST_CondRetOK ;

} /* Fim função: LST  Inserir elemento após */
예제 #5
0
   LIS_tpCondRet LIS_InserirElementoApos( LIS_tppLista pLista ,
                                          void * pValor        )
   {

      tpElemLista * pElem ;

		 if ( pLista == NULL ) /* Lista não existe */
		 {
			 return LIS_CondRetListaNaoExiste;
		 } /* if */

      /* Criar elemento a inserir após */

         pElem = CriarElemento( pLista , pValor ) ;
         if ( pElem == NULL )
         {
            return LIS_CondRetFaltouMemoria ;
         } /* if */

		  #ifdef _DEBUG
         CED_DefinirTipoEspaco( pElem, LIS_TipoEspacoElemento ) ;
      #endif

      /* Encadear o elemento após o elemento */

         if ( pLista->pElemCorr == NULL )
         {
            pLista->pOrigemLista = pElem ;
            pLista->pFimLista = pElem ;
         } else
         {
            if ( pLista->pElemCorr->pProx != NULL )
            {
               pElem->pProx  = pLista->pElemCorr->pProx ;
               pLista->pElemCorr->pProx->pAnt = pElem ;
            } else
            {
               pLista->pFimLista = pElem ;
            } /* if */

            pElem->pAnt = pLista->pElemCorr ;
            pLista->pElemCorr->pProx = pElem ;

         } /* if */
                  
         pLista->pElemCorr = pElem ;
                  
         return LIS_CondRetOK ;

   } /* Fim função: LIS  &Inserir elemento após */
예제 #6
0
LIS_tpCondRet LIS_InserirElementoApos(LIS_tppLista pLista,
	void * pValor)

{

	tpElemLista * pElem;

#ifdef _DEBUG
	assert(pLista != NULL);
#endif

	/* Criar elemento a inerir após */

	pElem = CriarElemento(pLista, pValor);
	if (pElem == NULL)
	{
		return LIS_CondRetFaltouMemoria;
	} /* if */

	/* Encadear o elemento após o elemento */

	if (pLista->pElemCorr == NULL)
	{
		pLista->pOrigemLista = pElem;
		pLista->pFimLista = pElem;
	}
	else
	{
		if (pLista->pElemCorr->pProx != NULL)
		{
			pElem->pProx = pLista->pElemCorr->pProx;
			pLista->pElemCorr->pProx->pAnt = pElem;
		}
		else
		{
			pLista->pFimLista = pElem;
		} /* if */

		pElem->pAnt = pLista->pElemCorr;
		pLista->pElemCorr->pProx = pElem;

	} /* if */

	pLista->pElemCorr = pElem;

	return LIS_CondRetOK;

} /* Fim função: LIS  &Inserir elemento após */
예제 #7
0
   LIS_tpCondRet LIS_InserirElementoAntes( LIS_tppLista pLista ,
	   void * pValor        )
   {

	   tpElemLista * pElem ;

#ifdef _DEBUG
	   assert( pLista != NULL ) ;
#endif

#ifdef _DEBUG
	   CNT_CONTAR( "InserirElementoAntes" ) ;
#endif
	   /* Criar elemento a inerir antes */

	   pElem = CriarElemento( pLista , pValor ) ;
	   if ( pElem == NULL )
	   {
		   return LIS_CondRetFaltouMemoria ;
	   } /* if */

	   /* Encadear o elemento antes do elemento corrente */

	   if ( pLista->pElemCorr == NULL )
	   {
		   pLista->pOrigemLista = pElem ;
		   pLista->pFimLista = pElem ;

#ifdef _DEBUG
		   CNT_CONTAR( "InserirElementoAntesif1" ) ;
#endif
	   } 
	   else
	   {
#ifdef _DEBUG
		   CNT_CONTAR( "InserirElementoAnteselse0" ) ;
#endif
		   if ( pLista->pElemCorr->pAnt != NULL )
		   {
			   pElem->pAnt  = pLista->pElemCorr->pAnt ;
			   pLista->pElemCorr->pAnt->pProx = pElem ;

#ifdef _DEBUG
			   CNT_CONTAR( "InserirElementoAntesif2" ) ;
#endif

		   } else
		   {
#ifdef _DEBUG
			   CNT_CONTAR( "InserirElementoAnteselse1" ) ;
#endif
			   pLista->pOrigemLista = pElem ;
		   } /* if */

		   pElem->pProx = pLista->pElemCorr ;
		   pLista->pElemCorr->pAnt = pElem ;
	   } /* if */

	   pLista->pElemCorr = pElem ;

	   return LIS_CondRetOK ;

   } /* Fim função: LIS  &Inserir elemento antes */
예제 #8
0
LIS_tpCondRet LIS_InserirElementoApos( LIS_tppLista lista, void * pValor
                                       #ifdef _DEBUG
                                       , LIS_tpTipo tipo
                                       #endif
                                     )
   {

      tpElemLista * pElem ;

      #ifdef _DEBUG
         assert( lista != NULL ) ;
      #endif

      /* Criar elemento a inerir após */

      pElem = CriarElemento( lista , pValor
                             #ifdef _DEBUG
                             , tipo
                             #endif
                           ) ;
      if ( pElem == NULL )
      {
         #ifdef _DEBUG
            CNT_CONTAR( "LIS_InserirElementoApos_FaltouMemoria" ) ;
         #endif
         return LIS_CondRetFaltouMemoria ;
      } /* if */

      /* Encadear o elemento após o elemento */

      if ( lista->pElemCorr == NULL )
      {
         #ifdef _DEBUG
            CNT_CONTAR( "LIS_InserirElementoApos_CorrNULL" ) ;
         #endif
         lista->pOrigemLista = pElem ;
         lista->pFimLista = pElem ;
      } else
      {
         if ( lista->pElemCorr->pProx != NULL )
         {
            #ifdef _DEBUG
               CNT_CONTAR( "LIS_InserirElementoApos_Prox" ) ;
            #endif
            pElem->pProx  = lista->pElemCorr->pProx ;
            lista->pElemCorr->pProx->pAnt = pElem ;
         } else
         {
            #ifdef _DEBUG
               CNT_CONTAR( "LIS_InserirElementoApos_ProxNULL" ) ;
            #endif
            lista->pFimLista = pElem ;
         } /* if */

         pElem->pAnt = lista->pElemCorr ;
         lista->pElemCorr->pProx = pElem ;

      } /* if */

      lista->pElemCorr = pElem ;

      return LIS_CondRetOK ;

   } /* Fim função: LIS &Inserir elemento após */
예제 #9
0
   LIS_tpCondRet LIS_InserirElementoAntes( LIS_tppLista lista , void * pValor
                                           #ifdef _DEBUG
                                           , LIS_tpTipo tipo
                                           #endif
                                         )
   {

      tpElemLista * pElem ;

      #ifdef _DEBUG
         assert( lista != NULL ) ;
      #endif

      /* Criar elemento a inerir antes */

      pElem = CriarElemento( lista , pValor
                             #ifdef _DEBUG
                             , tipo
                             #endif
                           ) ;
      if ( pElem == NULL )
      {
         #ifdef _DEBUG
            CNT_CONTAR( "LIS_InserirElementoAntes_FaltouMemoria" ) ;
         #endif
         return LIS_CondRetFaltouMemoria ;
      } /* if */

      /* Encadear o elemento antes do elemento corrente */

      if ( lista->pElemCorr == NULL )
      {
         #ifdef _DEBUG
            CNT_CONTAR( "LIS_InserirElementoAntes_CorrNULL" ) ;
         #endif
         lista->pOrigemLista = pElem ;
         lista->pFimLista = pElem ;
      } else
      {
         if ( lista->pElemCorr->pAnt != NULL )
         {
            #ifdef _DEBUG
               CNT_CONTAR( "LIS_InserirElementoAntes_Ant" ) ;
            #endif
            pElem->pAnt  = lista->pElemCorr->pAnt ;
            lista->pElemCorr->pAnt->pProx = pElem ;
         } else
         {
            #ifdef _DEBUG
               CNT_CONTAR( "LIS_InserirElementoAntes_AntNULL" ) ;
            #endif
            lista->pOrigemLista = pElem ;
         } /* if */

         pElem->pProx = lista->pElemCorr ;
         lista->pElemCorr->pAnt = pElem ;
      } /* if */

      #ifdef _DEBUG
         CED_DefinirTipoEspaco( pElem , tipo ) ;
      #endif

      lista->pElemCorr = pElem ;

      return LIS_CondRetOK ;

   } /* Fim função: LIS &Inserir elemento antes */