[BACK]Return to pieri_trees_io.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Schubert

Annotation of OpenXM_contrib/PHC/Ada/Schubert/pieri_trees_io.adb, Revision 1.1

1.1     ! maekawa     1: with integer_io;                         use integer_io;
        !             2: with Standard_Natural_Vectors_io;        use Standard_Natural_Vectors_io;
        !             3: with Brackets_io;                        use Brackets_io;
        !             4:
        !             5: package body Pieri_Trees_io is
        !             6:
        !             7:   type Boolean_Array is array ( integer range <> ) of boolean;
        !             8:
        !             9:   procedure put ( nd : in Pieri_Node ) is
        !            10:   begin
        !            11:     put(Standard_Output,nd);
        !            12:   end put;
        !            13:
        !            14:   procedure put ( file : in file_type; nd : in Pieri_Node ) is
        !            15:   begin
        !            16:     put(file,nd.node);
        !            17:     put(file,"(c="); put(file,nd.c,1);
        !            18:     put(file,",i="); put(file,nd.i,1);
        !            19:     put(file,",h="); put(file,nd.h,1); put(file,")");
        !            20:   end put;
        !            21:
        !            22:   procedure put ( lnd : in Link_to_Pieri_Node ) is
        !            23:   begin
        !            24:     put(Standard_Output,lnd);
        !            25:   end put;
        !            26:
        !            27:   procedure put ( file : in file_type; lnd : in Link_to_Pieri_Node ) is
        !            28:   begin
        !            29:     put(file,lnd.all);
        !            30:     if lnd.ancestor /= null
        !            31:      then put(file," > ");
        !            32:           put(file,lnd.ancestor);
        !            33:     end if;
        !            34:   end put;
        !            35:
        !            36:   procedure put ( t : in Pieri_Tree ) is
        !            37:   begin
        !            38:     put(Standard_Output,t);
        !            39:   end put;
        !            40:
        !            41:   procedure put ( t : in Pieri_Tree; level : in natural ) is
        !            42:   begin
        !            43:     put(Standard_Output,t,level);
        !            44:   end put;
        !            45:
        !            46:   procedure put ( file : in file_type;
        !            47:                   t : in Pieri_Tree; level : in natural ) is
        !            48:
        !            49:     procedure Write_Node ( lnd : in Link_to_Pieri_Node;
        !            50:                            continue : out boolean ) is
        !            51:     begin
        !            52:       put(file,lnd.all);
        !            53:       continue := true;
        !            54:     end Write_Node;
        !            55:     procedure Write_Nodes is new Enumerate_Nodes(Write_Node);
        !            56:
        !            57:   begin
        !            58:     Write_Nodes(t,level);
        !            59:   end put;
        !            60:
        !            61:   procedure put ( file : in file_type; t : in Pieri_Tree ) is
        !            62:
        !            63:     h : constant natural := Height(t);
        !            64:
        !            65:   begin
        !            66:     put(file,"Branching at "); put(file,t.branches); new_line(file);
        !            67:     put(file,"Root node : "); put(file,t.root.node); new_line(file);
        !            68:     for i in reverse 1..h loop
        !            69:       put(file,"Nodes at level "); put(file,i,1); put(file," :");
        !            70:       put(file,t,i); new_line(file);
        !            71:     end loop;
        !            72:   end put;
        !            73:
        !            74:   function Last_Child ( nd : Pieri_Node; i : natural ) return boolean is
        !            75:
        !            76:   -- DESCRIPTION :
        !            77:   --   Returns true if the ith child is the last child of the node.
        !            78:
        !            79:   begin
        !            80:     for j in (i+1)..nd.children'last loop
        !            81:       if nd.children(j) /= null
        !            82:        then return false;
        !            83:       end if;
        !            84:     end loop;
        !            85:     return true;
        !            86:   end Last_Child;
        !            87:
        !            88:   procedure Write_Labels ( file : in file_type;
        !            89:                            nd : in Pieri_Node; jump : in natural;
        !            90:                            last : in Boolean_Array ) is
        !            91:
        !            92:   -- DESCRIPTION :
        !            93:   --   Writes the contents of the Pieri node with the jump, taking into
        !            94:   --   account which children appeared last.
        !            95:
        !            96:   begin
        !            97:     if nd.h /= 0
        !            98:      then put(file,"   ");
        !            99:     end if;
        !           100:     for i in 1..(nd.h-1) loop
        !           101:       if last(i)
        !           102:        then put(file,"     ");
        !           103:        else put(file,"|    ");
        !           104:       end if;
        !           105:     end loop;
        !           106:     if nd.h /= 0
        !           107:      then put(file,"!-+"); put(file,jump,1);
        !           108:     end if;
        !           109:     put(file,nd);
        !           110:     new_line(file);
        !           111:   end Write_Labels;
        !           112:
        !           113:   procedure Write_Nodes ( file : in file_type;
        !           114:                           nd : in Pieri_Node; jump : in natural;
        !           115:                           last : in out Boolean_Array ) is
        !           116:
        !           117:   -- DESCRIPTION :
        !           118:   --   Writes the contents of the Pieri node preceded with the index of
        !           119:   --   increase (jump), followed by the information on the children.
        !           120:
        !           121:   begin
        !           122:     Write_Labels(file,nd,jump,last);
        !           123:     for i in nd.children'range loop
        !           124:       if nd.children(i) /= null
        !           125:        then last(nd.h+1) := Last_Child(nd,i);
        !           126:             Write_Nodes(file,nd.children(i).all,i,last);
        !           127:       end if;
        !           128:     end loop;
        !           129:   end Write_Nodes;
        !           130:
        !           131:   procedure Write_Tree ( t : in Pieri_Tree ) is
        !           132:   begin
        !           133:     Write_Tree(Standard_Output,t);
        !           134:   end Write_Tree;
        !           135:
        !           136:   procedure Write_Tree ( file : in file_type; t : in Pieri_Tree ) is
        !           137:
        !           138:     last : Boolean_Array(1..Height(t));
        !           139:
        !           140:   begin
        !           141:     Write_Nodes(file,t.root.all,0,last);
        !           142:   end Write_Tree;
        !           143:
        !           144: end Pieri_Trees_io;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>