aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-11-20 08:34:27 +0100
committerTristan Gingold <tgingold@free.fr>2022-11-20 08:34:27 +0100
commitbd43c44ab5216e53bddc0e5c33cf8976db4d54b3 (patch)
tree89326123c8c09003735853dd7023c0c1b7689fbe /src/grt
parentbad897e392427190d2774269925e2bb21cf50a93 (diff)
downloadghdl-bd43c44ab5216e53bddc0e5c33cf8976db4d54b3.tar.gz
ghdl-bd43c44ab5216e53bddc0e5c33cf8976db4d54b3.tar.bz2
ghdl-bd43c44ab5216e53bddc0e5c33cf8976db4d54b3.zip
grt-algos: clarify the API
Diffstat (limited to 'src/grt')
-rw-r--r--src/grt/grt-algos.adb3
-rw-r--r--src/grt/grt-algos.ads8
-rw-r--r--src/grt/grt-waves.adb6
3 files changed, 11 insertions, 6 deletions
diff --git a/src/grt/grt-algos.adb b/src/grt/grt-algos.adb
index 6469e2b80..82c14bd8c 100644
--- a/src/grt/grt-algos.adb
+++ b/src/grt/grt-algos.adb
@@ -39,6 +39,9 @@ package body Grt.Algos is
end Bubble_Down;
begin
+ -- Note: if N < 2, there is nothing to sort. The loops are not
+ -- executed.
+
-- Heapify
for I in reverse 1 .. N / 2 loop
Bubble_Down (I, N);
diff --git a/src/grt/grt-algos.ads b/src/grt/grt-algos.ads
index 1197bcd7b..828960e11 100644
--- a/src/grt/grt-algos.ads
+++ b/src/grt/grt-algos.ads
@@ -15,12 +15,12 @@
-- along with this program. If not, see <gnu.org/licenses>.
package Grt.Algos is
- -- Heap sort the N elements.
+ -- Heap sort the N elements. Indexes are from 1 to N.
generic
- -- Compare two elements, return true iff OP1 < OP2.
- with function Lt (Op1, Op2 : Natural) return Boolean;
+ -- Compare two elements, return true iff L < R.
+ with function Lt (L, R : Positive) return Boolean;
-- Swap two elements.
- with procedure Swap (From : Natural; To : Natural);
+ with procedure Swap (P1 : Positive; P2 : Positive);
procedure Heap_Sort (N : Natural);
end Grt.Algos;
diff --git a/src/grt/grt-waves.adb b/src/grt/grt-waves.adb
index eb0f0a898..98a8538b3 100644
--- a/src/grt/grt-waves.adb
+++ b/src/grt/grt-waves.adb
@@ -1783,7 +1783,8 @@ package body Grt.Waves is
procedure Wave_Cycle
is
- function Lt (Op1, Op2 : Natural) return Boolean is
+ function Lt (Op1, Op2 : Positive) return Boolean
+ is
Left : Ghdl_Signal_Ptr;
Right : Ghdl_Signal_Ptr;
begin
@@ -1793,7 +1794,8 @@ package body Grt.Waves is
end Lt;
pragma Inline (Lt);
- procedure Swap (From, To : Natural) is
+ procedure Swap (From, To : Positive)
+ is
Tmp : Ghdl_Signal_Ptr;
begin
Tmp := Changed_Sig_Table.Table (From);