From f86bf7c198f91133355675f5553ab1f29dba1b65 Mon Sep 17 00:00:00 2001 From: iTakinn Date: Tue, 30 Jun 2026 10:59:07 -0300 Subject: [PATCH] remover removendo --- cpfs.pas | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cpfs.pas b/cpfs.pas index f98348d..4930e5e 100644 --- a/cpfs.pas +++ b/cpfs.pas @@ -32,7 +32,7 @@ function validacaoDeInexistencialismoDeOutroCadastroDePessoasFisicaDentroDaLista begin aux := cpfs[(charint(cpf[10]) *10+ charint(cpf[11]))]; existenciaDeTalInformacaoNaLista := false; - while (aux^.prox <> nil) and (not existenciaDeTalInformacaoNaLista) do + while (aux <> nil) and (not existenciaDeTalInformacaoNaLista) do begin if (cpf = aux^.cpf) then existenciaDeTalInformacaoNaLista := true @@ -158,22 +158,29 @@ procedure buscar(var cpfs:thash;cpf:string); procedure removerCPF(var cpfs:thash;cpf:string) ; var aux:^ptcpf; - aux2:^ptcpf; + ant:^ptcpf; achou:boolean; begin achou:=false; aux := cpfs[ (charint(cpf[10]) *10+ charint(cpf[11])) ]; - while (aux <> nil) and (not achou) do + while (aux <> nil) and (aux^.cpf <> cpf) do begin - if(aux^.cpf = cpf) then - begin - achou:=true; - aux2:=(aux^.prox) ; - end - else - aux:= aux^.prox - end; + ant := aux; + aux := aux^.prox; + end; + if aux <> nil then + begin + if ant = nil then + cpfs[(charint(cpf[10]) *10+ charint(cpf[11]))] := aux^.prox + else + ant^.prox := aux^.prox; + dispose(aux); + end; end; + + + + procedure cpfsInicializar ( var cpfs : thash ) ; var i : integer ;