Exemplo n.º 1
0
LIS_tpCondRet LIS_EsvaziarLista ( LIS_tppLista * pLista ) 
{

	tpElemLista * pElem ;

	/* Tratar lista inexistente */

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

	/* Tratar lista vazia */

	if ( (*pLista)->pOrigemLista == NULL )
	{
		return LIS_CondRetListaVazia;
	} /* if */ 
	
	/* fim ativa: Tratar lista vazia */

	if( (*pLista)->numElem == 0 )
	{
		(*pLista)->pElemCorr = NULL;

		LimparCabeca( (*pLista) ) ;

		return LIS_CondRetOK;
	}

	(*pLista)->pElemCorr = (*pLista)->pOrigemLista ;
	
	while ( (*pLista)->pElemCorr != NULL )
    {
		pElem = (*pLista)->pElemCorr;
		(*pLista)->pElemCorr = (*pLista)->pElemCorr->pProx;
		
		LiberarElemento( pElem, (*pLista)->ExcluirValor ) ;
        

    } /* while */ 

	(*pLista)->pElemCorr = NULL;

	LimparCabeca( (*pLista) ) ;

	return LIS_CondRetOK;

} /* Fim função: LIS  &Esvaziar lista */
Exemplo n.º 2
0
   void LIS_EsvaziarLista( LIS_tppLista pLista )
   {

      tpElemLista * pElem ;
      tpElemLista * pProx ;

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

      pElem = pLista->pOrigemLista ;
      while ( pElem != NULL )
      {
		#ifdef _DEBUG
		 CNT_CONTAR( "EsvaziarListaWhile" ) ;
		#endif
         pProx = pElem->pProx ;
         LiberarElemento( pLista , pElem ) ;
         pElem = pProx ;
      } /* while */

      LimparCabeca( pLista ) ;

   } /* Fim função: LIS  &Esvaziar lista */
Exemplo n.º 3
0
   LIS_tppLista LIS_CriarLista(
             void   ( * ExcluirValor ) ( void * pDado ) )
   {

      LIS_tpLista * pLista = NULL ;

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

      pLista = ( LIS_tpLista * ) malloc( sizeof( LIS_tpLista )) ;
      if ( pLista == NULL )
      {
         return NULL ;
      } /* if */

      LimparCabeca( pLista ) ;

      pLista->ExcluirValor = ExcluirValor ;

	#ifdef _DEBUG
         CED_DefinirTipoEspaco( pLista , LIS_TipoCabeca ) ;
    #endif

      return pLista ;

   } /* Fim função: LIS  &Criar lista */
Exemplo n.º 4
0
void LST_EsvaziarLista( TpLista * pLista , void ( * ExcluirValor) ( void * pDado)  )
{
	TpNoLista * pElem ;
	TpNoLista * pProx ;

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

	pLista->pNoCorrente = pLista->pOrigemLista ;
	while ( pLista->pNoCorrente != NULL )
	{
		pElem = pLista->pNoCorrente;
		pLista ->pNoCorrente = pLista->pNoCorrente->pProx;

		LiberarNo( pLista , pElem, ExcluirValor ) ;
	} /* while */


	LimparCabeca ( pLista 
#ifdef _DEBUG
		, ' '
#endif
		);
	pLista->pNoCorrente=NULL;

} /* Fim função: LST Esvaziar lista duplamente encadeada*/
Exemplo n.º 5
0
TpLista * LST_CriarLista ( 
#ifdef _DEBUG
	char tipoElem
#endif
	)
{
	TpLista * pLista;

	pLista = ( TpLista * )malloc( sizeof( TpLista )) ;
	/* alocar espaço para lista */

	if ( pLista== NULL )
	{
		printf ( " Espaço na memória insuficiente " ) ;
		return NULL ;
	} /* if */

#ifdef _DEBUG
	CED_MarcarEspacoAtivo( pLista );
#endif

	LimparCabeca( pLista 
#ifdef _DEBUG
		, tipoElem
#endif
		) ; 
	/*zerar todos os campos da estrutura.*/

	return pLista ;

} /* Fim função: LST Criar lista genérica duplamente encadeada*/
Exemplo n.º 6
0
   LIS_tpCondRet LIS_EsvaziarLista( LIS_tppLista lista )
   {

      tpElemLista * pElem ;
      tpElemLista * pProx ;

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

      pElem = lista->pOrigemLista ;
      while ( pElem != NULL )
      {
         #ifdef _DEBUG
            CNT_CONTAR( "LIS_EsvaziarLista_while" ) ;
         #endif

         pProx = pElem->pProx ;
         LiberarElemento( lista , pElem ) ;
         pElem = pProx ;
      } /* while */

      LimparCabeca( lista ) ;

     return LIS_CondRetOK;

   } /* Fim função: LIS &Esvaziar lista */
Exemplo n.º 7
0
   LIS_tpCondRet LIS_CriarLista( LIS_tppLista * pLista,
                                 void (* pExcluir)( void * pValor))
   {

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

      *pLista = ( LIS_tppLista ) malloc( sizeof( LIS_tpLista )) ;
      if ( *pLista == NULL )
      {
         #ifdef _DEBUG
            CNT_CONTAR( "LIS_CriarLista_FaltouMemoria" ) ;
         #endif
         return LIS_CondRetFaltouMemoria ;
      } /* if */

      #ifdef _DEBUG
         CED_DefinirTipoEspaco( *pLista , LIS_EspacoCabeca ) ;
         CNT_CONTAR( "LIS_CriarLista" ) ;
      #endif

      LimparCabeca( *pLista ) ;
      (*pLista)->pExcluir = pExcluir ;

      return LIS_CondRetOK;

   } /* Fim função: LIS &Criar lista */
Exemplo n.º 8
0
LIS_tpCondRet LIS_CriarLista ( LIS_tppLista * refLista, void ( *ExcluirConteudo ) ( void * pConteudo ) )
{

	/* Tratar lista inexistente */
	
	if ( (*refLista) != NULL ) 
	{
		return LIS_CondRetListaJaExiste;
	} /* if */ 
	
	/* fim ativa: Tratar ista inexistente */

	( *refLista ) = ( LIS_tppLista ) malloc ( sizeof ( LIS_tpLista ) );
	if ( ( *refLista ) == NULL )
	{
		return LIS_CondRetFaltouMemoria;
	} /* if */

	LimparCabeca ( *refLista );

	(*refLista)->ExcluirValor = ExcluirConteudo;

	return LIS_CondRetOK;

} /* Fim função: LIS  &Criar lista genérica duplamente encadeada */
Exemplo n.º 9
0
   LIS_tppLista LIS_CriarLista(
             void   ( * ExcluirValor ) ( void * pDado ) )
   {

      LIS_tpLista * pLista = NULL ;

      pLista = ( LIS_tpLista * ) malloc( sizeof( LIS_tpLista )) ;
      if ( pLista == NULL )
      {
         return NULL ;
      } /* if */

      LimparCabeca( pLista ) ;

      pLista->ExcluirValor = ExcluirValor ;

      return pLista ;

   } /* Fim função: LIS  &Criar lista */
Exemplo n.º 10
0
void LIS_EsvaziarLista( LIS_tppLista pLista )
{

    LIS_tpElemLista *pElem ;
    LIS_tpElemLista *pProx ;

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

    pElem = pLista->pOrigemLista ;
    while ( pElem != NULL )
    {
        pProx = pElem->pProx ;
        LiberarElemento( pLista , pElem ) ;
        pElem = pProx ;
    } /* while */

    LimparCabeca( pLista ) ;

} /* Fim funcao: LIS  &Esvaziar lista */
Exemplo n.º 11
0
   LIS_tpCondRet LIS_CriarLista( LIS_tppLista *ppLista ,
             void   ( * ExcluirValor ) ( void * pDado ) )
   {
	  
      *ppLista = ( LIS_tpLista * ) malloc( sizeof( LIS_tpLista )) ;
      if ( *ppLista == NULL )
      {
         return LIS_CondRetFaltouMemoria ;
      } /* if */

      LimparCabeca( *ppLista ) ;

      (*ppLista)->ExcluirValor = ExcluirValor ;

	#ifdef _DEBUG
		CED_DefinirTipoEspaco(*ppLista,LIS_TipoEspacoElemento);
	#endif

      return LIS_CondRetOK ; 

   } /* Fim função: LIS  &Criar lista */
Exemplo n.º 12
0
   LIS_tpCondRet LIS_CriarLista(
             void   ( * ExcluirValor ) ( void * pDado ) , LIS_tppLista * pLista)
   {

      LIS_tpLista * pListaM = NULL ;

      pListaM = ( LIS_tpLista * ) malloc( sizeof( LIS_tpLista )) ;
      if ( pListaM == NULL )
      {
		  return LIS_CondRetFaltouMemoria ;
      } /* if */

      LimparCabeca( pListaM ) ;

      pListaM->ExcluirValor = ExcluirValor ;

	  (*pLista) = ( LIS_tppLista ) malloc( sizeof( LIS_tpLista )) ;

	  (*pLista) = pListaM ;

	  return LIS_CondRetOK ;

   } /* Fim função: LIS  &Criar lista */
Exemplo n.º 13
0
Arquivo: LISTA.C Projeto: Rifeli/t4
LIS_tppLista LIS_CriarLista(
	void   ( * ExcluirValor ) ( void * pDado ) )
{

	LIS_tpLista * pLista = NULL ;

	pLista = ( LIS_tpLista * ) malloc( sizeof( LIS_tpLista )) ;
	if ( pLista == NULL )
	{
		return NULL ;
	} /* if */

#ifdef _DEBUG
	CED_MarcarEspacoAtivo(pLista);
#endif

	LimparCabeca( pLista ) ;

	pLista->ExcluirValor = ExcluirValor ;

	return pLista ;

} /* Fim função: LIS  &Criar lista */
Exemplo n.º 14
0
   LIS_tpCondRet LIS_EsvaziarLista( LIS_tppLista pLista )
   {

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

      pElem = pLista->pOrigemLista ;
      while ( pElem != NULL )
      {
         pProx = pElem->pProx ;
         LiberarElemento( pLista , pElem ) ;
         pElem = pProx ;
      } /* while */

      LimparCabeca( pLista ) ;

	  return LIS_CondRetOK;

   } /* Fim função: LIS  &Esvaziar lista */