1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
with Glib; use Glib;
with Gtk.Enums;
with Ada.Text_IO; use Ada.Text_IO;
procedure Glist_Traverse is
use Gtk.Enums.Gint_List;
List : Gtk.Enums.Gint_List.Glist;
Temp : Gtk.Enums.Gint_List.Glist;
begin
-- First step: create a new list.
Prepend (List, 2); -- add at the beginning of the list
Append (List, 3); -- add at the end of the list
Insert (List, Data => 1, Position => 1); -- in the middle of the list
-- Traverse the list (first way)
Temp := First (List);
while Temp /= Null_List loop
Put_Line (Gint'Image (Get_Data (Temp)));
Temp := Next (Temp);
end loop;
-- Traverse the list (second way)
for I in 1 .. Length (List) loop
Put_Line (Gint'Image (Nth_Data (List, I - 1)));
end loop;
end Glist_Traverse;
|