ajout rapide de is_sorted_and_uniq
git-svn-id: http://cregut.svn.enseeiht.fr/2020/1sn/pim/projets/GH-05@210410 e13453a9-b01f-0410-a051-f404c4f0c485
This commit is contained in:
parent
8208062b99
commit
42da1b9473
1
Makefile
1
Makefile
|
@ -1,4 +1,5 @@
|
|||
make:
|
||||
make clean && \
|
||||
cd build/ && \
|
||||
gnat make -gnatwa -gnata -g ../src/*.adb
|
||||
|
||||
|
|
|
@ -41,9 +41,11 @@ $ make test
|
|||
- sortir quicksort et en faire un module générique
|
||||
- procédure pour compter les doublons dans le réseau
|
||||
- robustesse doublon args
|
||||
|
||||
- revoir l'algo de tri, trier que la première colonne
|
||||
- faire en sorte de détecter les dupes dans al seconde colonne non triées.
|
||||
- faire des sous-lib Google
|
||||
|
||||
https://www.youtube.com/watch?v=JCdgUrTVbLc
|
||||
# question à poser
|
||||
worm precision 10 broken
|
||||
brainlinks.ord broken décalage de 1, pas de page 0
|
||||
brainlinks.ord broken décalage de 1, pas de page 0
|
||||
|
|
|
@ -183,6 +183,8 @@ begin
|
|||
|
||||
network: Vector_Link.T_Vecteur;
|
||||
row, col: Natural;
|
||||
|
||||
sorted: Boolean;
|
||||
dupe: Natural;
|
||||
|
||||
pi: Vector_Double.T_Vecteur;
|
||||
|
@ -200,9 +202,16 @@ begin
|
|||
put_line("loaded in memory the network");
|
||||
|
||||
-- on trie le réseau, si besoin
|
||||
if not naif then -- and then not(is_sorted(network)) then
|
||||
quicksort(network);
|
||||
put_line("sorted the network");
|
||||
is_sorted_and_uniq(network, dupe, sorted);
|
||||
if not naif then
|
||||
if not sorted then
|
||||
put_line("network is not sorted");
|
||||
quicksort(network);
|
||||
put_line("sorted the network");
|
||||
end if;
|
||||
if dupe > 0 then
|
||||
put_line("deleted the duplicates ####### TODO #######");
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- on compte le nombre de doublons
|
||||
|
|
|
@ -245,6 +245,21 @@ package body Vector is
|
|||
end loop;
|
||||
end put;
|
||||
|
||||
procedure is_sorted_and_uniq(vec: in T_Vecteur; dupe: out Natural; sorted: out Boolean) is
|
||||
last: T_Link := vec(0);
|
||||
begin
|
||||
sorted := True;
|
||||
dupe := 0;
|
||||
for i in 1..Capacite-1 loop
|
||||
if vec(i) < last then
|
||||
sorted := False;
|
||||
elsif vec(i) = last then
|
||||
dupe := dupe + 1;
|
||||
end if;
|
||||
last := vec(i);
|
||||
end loop;
|
||||
end is_sorted_and_uniq;
|
||||
|
||||
function "<"(left, right: in T_Link) return Boolean is
|
||||
begin
|
||||
if left.from < right.from then
|
||||
|
|
|
@ -71,8 +71,8 @@ package Vector is
|
|||
|
||||
procedure put(vec: in T_Vecteur);
|
||||
|
||||
procedure is_sorted_and_uniq(vec: in T_Vecteur; dupe: out Natural; sorted: out Boolean);
|
||||
function "<"(left, right: in T_Link) return Boolean;
|
||||
|
||||
procedure quicksort(vec: in out T_Vecteur; low: Natural := 0; high: Natural := Capacite-1);
|
||||
|
||||
end Link;
|
||||
|
|
Loading…
Reference in a new issue