Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ponerEnListaAcumulandoDuplicados(
- tLista* p,
- const tInfo* d,
- int(*cmp)(const tInfo*,const tInfo*),
- void(*acum)(tInfo*,const tInfo*)
- )
- ///VER LISTA
- ///PREPARACION DE LOS PUNTEROS VERIFICANDO BORDES Y COMPARANDO
- ///PREPARACION DEL NUEVO NODO
- ///CONEXION DE LA LISTA CON EL NUEVO NODO
- {
- tNodo* nue,
- * act=*p,
- * sig,
- * ant;
- int comparacion;
- if(act==NULL)
- {
- sig=NULL;
- ant=NULL;
- }
- else
- {
- while(act->sig&&cmp(d,&act->info)>0)
- act=act->sig;
- while(act->ant&&cmp(d,&act->info)<0)
- act=act->ant;
- //ACT LISTO
- comparacion=cmp(d,&act->info);
- if(comparacion==0)
- {
- acum(&act->info,d);
- return 2;
- }
- if(comparacion<0)
- {
- sig=act;
- ant=act->ant;
- }
- else
- {
- sig=act->sig;
- ant=act;
- }
- //PUNTEROS LISTOS
- }
- //PREPARACION DEL NODO
- nue=(tNodo*)malloc(sizeof(tNodo));
- if(!nue)
- return 1;
- nue->info=*d;
- nue->sig=sig;
- nue->ant=ant;
- //CABLEADO
- if(ant)
- ant->sig=nue;
- if(sig)
- sig->ant=nue;
- *p=nue;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement