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:
|
||||||
|
make clean && \
|
||||||
cd build/ && \
|
cd build/ && \
|
||||||
gnat make -gnatwa -gnata -g ../src/*.adb
|
gnat make -gnatwa -gnata -g ../src/*.adb
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ $ make test
|
||||||
- sortir quicksort et en faire un module générique
|
- sortir quicksort et en faire un module générique
|
||||||
- procédure pour compter les doublons dans le réseau
|
- procédure pour compter les doublons dans le réseau
|
||||||
- robustesse doublon args
|
- 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
|
https://www.youtube.com/watch?v=JCdgUrTVbLc
|
||||||
# question à poser
|
# question à poser
|
||||||
|
|
|
@ -183,6 +183,8 @@ begin
|
||||||
|
|
||||||
network: Vector_Link.T_Vecteur;
|
network: Vector_Link.T_Vecteur;
|
||||||
row, col: Natural;
|
row, col: Natural;
|
||||||
|
|
||||||
|
sorted: Boolean;
|
||||||
dupe: Natural;
|
dupe: Natural;
|
||||||
|
|
||||||
pi: Vector_Double.T_Vecteur;
|
pi: Vector_Double.T_Vecteur;
|
||||||
|
@ -200,10 +202,17 @@ begin
|
||||||
put_line("loaded in memory the network");
|
put_line("loaded in memory the network");
|
||||||
|
|
||||||
-- on trie le réseau, si besoin
|
-- on trie le réseau, si besoin
|
||||||
if not naif then -- and then not(is_sorted(network)) then
|
is_sorted_and_uniq(network, dupe, sorted);
|
||||||
|
if not naif then
|
||||||
|
if not sorted then
|
||||||
|
put_line("network is not sorted");
|
||||||
quicksort(network);
|
quicksort(network);
|
||||||
put_line("sorted the network");
|
put_line("sorted the network");
|
||||||
end if;
|
end if;
|
||||||
|
if dupe > 0 then
|
||||||
|
put_line("deleted the duplicates ####### TODO #######");
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
|
||||||
-- on compte le nombre de doublons
|
-- on compte le nombre de doublons
|
||||||
-- count_dupe(network, dupe);
|
-- count_dupe(network, dupe);
|
||||||
|
|
|
@ -245,6 +245,21 @@ package body Vector is
|
||||||
end loop;
|
end loop;
|
||||||
end put;
|
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
|
function "<"(left, right: in T_Link) return Boolean is
|
||||||
begin
|
begin
|
||||||
if left.from < right.from then
|
if left.from < right.from then
|
||||||
|
|
|
@ -71,8 +71,8 @@ package Vector is
|
||||||
|
|
||||||
procedure put(vec: in T_Vecteur);
|
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;
|
function "<"(left, right: in T_Link) return Boolean;
|
||||||
|
|
||||||
procedure quicksort(vec: in out T_Vecteur; low: Natural := 0; high: Natural := Capacite-1);
|
procedure quicksort(vec: in out T_Vecteur; low: Natural := 0; high: Natural := Capacite-1);
|
||||||
|
|
||||||
end Link;
|
end Link;
|
||||||
|
|
Loading…
Reference in a new issue