File: glist_traverse.adb

package info (click to toggle)
libgtkada 2.24.4dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,208 kB
  • ctags: 1,676
  • sloc: ada: 119,686; ansic: 4,719; sh: 3,003; makefile: 690; xml: 338; perl: 70
file content (31 lines) | stat: -rw-r--r-- 823 bytes parent folder | download | duplicates (6)
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;