1--  Copyright 1999-2014 Simon Wright <simon@pushface.org>
2
3--  This package is free software; you can redistribute it and/or
4--  modify it under terms of the GNU General Public License as
5--  published by the Free Software Foundation; either version 2, or
6--  (at your option) any later version. This package is distributed in
7--  the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8--  even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9--  PARTICULAR PURPOSE. See the GNU General Public License for more
10--  details. You should have received a copy of the GNU General Public
11--  License distributed with this package; see file COPYING.  If not,
12--  write to the Free Software Foundation, 59 Temple Place - Suite
13--  330, Boston, MA 02111-1307, USA.
14
15--  As a special exception, if other files instantiate generics from
16--  this unit, or you link this unit with other files to produce an
17--  executable, this unit does not by itself cause the resulting
18--  executable to be covered by the GNU General Public License.  This
19--  exception does not however invalidate any other reasons why the
20--  executable file might be covered by the GNU Public License.
21
22with Ada.Text_IO;
23procedure BC.Trees.AVL_Trees.Print (T : AVL_Tree) is
24   use Ada.Text_IO;
25   procedure Print_Node (N : AVL_Node_Ref; Indent : Natural);
26   procedure Print_Node (N : AVL_Node_Ref; Indent : Natural) is
27   begin
28      if N.Left /= null then
29         Print_Node (N.Left, Indent + 1);
30      end if;
31      for I in 1 .. Indent loop
32         Put ("  ");
33      end loop;
34      Put ("element: " & Image (N.Element));
35      Put (" (" & Node_Balance'Image (N.Balance) & ")");
36      New_Line;
37      if N.Right /= null then
38         Print_Node (N.Right, Indent + 1);
39      end if;
40   end Print_Node;
41begin
42   Put_Line ("tree of size" & Natural'Image (T.Size));
43   Print_Node (T.Rep, 0);
44end BC.Trees.AVL_Trees.Print;
45