1--  Copyright 1994 Grady Booch
2--  Copyright 1998-2014 Simon Wright <simon@pushface.org>
3
4--  This package is free software; you can redistribute it and/or
5--  modify it under terms of the GNU General Public License as
6--  published by the Free Software Foundation; either version 2, or
7--  (at your option) any later version. This package is distributed in
8--  the hope that it will be useful, but WITHOUT ANY WARRANTY; without
9--  even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10--  PARTICULAR PURPOSE. See the GNU General Public License for more
11--  details. You should have received a copy of the GNU General Public
12--  License distributed with this package; see file COPYING.  If not,
13--  write to the Free Software Foundation, 59 Temple Place - Suite
14--  330, Boston, MA 02111-1307, USA.
15
16--  As a special exception, if other files instantiate generics from
17--  this unit, or you link this unit with other files to produce an
18--  executable, this unit does not by itself cause the resulting
19--  executable to be covered by the GNU General Public License.  This
20--  exception does not however invalidate any other reasons why the
21--  executable file might be covered by the GNU Public License.
22
23procedure BC.Containers.Trees.Binary.Pre_Order
24  (T : Binary_Tree; Success : out Boolean) is
25   Subtree : Binary_Tree;
26   Result : Boolean;
27begin
28   Success := True;
29   if not Is_Null (T) then
30      Apply (T.Rep.Element, Result);
31      if not Result then
32         Success := False;
33         return;
34      end if;
35      Subtree := T;
36      Left_Child (Subtree);
37      Pre_Order (Subtree, Result);
38      if not Result then
39         Success := False;
40         return;
41      end if;
42      Subtree := T;
43      Right_Child (Subtree);
44      Pre_Order (Subtree, Result);
45      if not Result then
46         Success := False;
47         return;
48      end if;
49   end if;
50end BC.Containers.Trees.Binary.Pre_Order;
51