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.Multiway.Post_Order
24  (T : Multiway_Tree; Success : out Boolean) is
25   Result : Boolean;
26begin
27   Success := True;
28   if not Is_Null (T) then
29      for I in 1 .. Arity (T) loop
30         declare
31            Subtree : Multiway_Tree := T;
32         begin
33            Child (Subtree, I);
34            Post_Order (Subtree, Result);
35            if not Result then
36               Success := False;
37               return;
38            end if;
39         end;
40      end loop;
41      Apply (T.Rep.Element, Result);
42      if not Result then
43         Success := False;
44         return;
45      end if;
46   end if;
47end BC.Containers.Trees.Multiway.Post_Order;
48