This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch corrects the implementation of routine Insert_Child in the following multiway tree packages: Ada.Containers.Indefinite_Multiway_Trees Ada.Containers.Multiway_Trees As a result, Insert_Child no longer returns a faulty Position when inserting elements. ------------ -- Source -- ------------ -- multi_main.adb with Ada.Containers.Multiway_Trees; with Ada.Text_IO; use Ada.Text_IO; procedure Multi_Main is Size : constant := 4; type Small_Int is new Integer range 1 .. 9 with Default_Value => 1; package MWT is new Ada.Containers.Multiway_Trees (Small_Int); use MWT; procedure Print_Tree (T : Tree) is procedure Output (C : Cursor) is begin Put_Line (Element (C)'Img); end Output; begin T.Iterate (Output'Access); end Print_Tree; T : Tree; R : constant Cursor := T.Root; C : Cursor; begin for Index in 1 .. Size loop T.Prepend_Child (R, 8); end loop; T.Clear; T.Insert_Child (Parent => R, Before => No_Element, Position => C, Count => 1); T.Insert_Child (Parent => R, Before => C, Position => C, New_Item => 2, Count => 2); Print_Tree (T); end Multi_Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q multi_main.adb $ ./multi_main 2 2 1 Tested on x86_64-pc-linux-gnu, committed on trunk 2014-10-30 Hristian Kirtchev <kirtchev@adacore.com> * a-comutr.adb, a-cimutr.adb (Insert_Child): Add new variable First. Update the position after all insertions have taken place.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |