comp.lang.ada
 help / color / mirror / Atom feed
* How to use Multiway_Trees
@ 2017-04-09 15:36 Mart van de Wege
  2017-04-09 16:27 ` Niklas Holsti
  0 siblings, 1 reply; 6+ messages in thread
From: Mart van de Wege @ 2017-04-09 15:36 UTC (permalink / raw)


I was interested in using Ada.Containers.Multiway_Trees in another
project, so I wrote some Proof of Concept code to see if I understood
correctly how to use it.

However, even the most simple use case, the following code, raises a
Program_Error:

raised PROGRAM_ERROR : Tree_Test.Test_Tree.Replace_Element: Position cursor designates root

with Ada.Text_Io;
with Ada.Containers.Multiway_Trees;
procedure Test_Tree is
   type String_Access is access String;
   package Tr is new Ada.Containers.Multiway_Trees
     ( Element_Type => String_Access );
   use Tr;
   T : Tree := Empty_Tree;
   C : Cursor := Root(T);
begin
   T.Insert_Child(Parent => C,
                  Before => No_Element,
                  New_Item => new String'("Test"));
end Test_Tree;

How do I create a tree if I can't even insert a child under the root
node?

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-12  8:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-09 15:36 How to use Multiway_Trees Mart van de Wege
2017-04-09 16:27 ` Niklas Holsti
2017-04-09 16:34   ` Simon Wright
2017-04-09 16:49     ` Mart van de Wege
2017-04-11 19:56       ` Dirk Heinrichs
2017-04-12  8:15         ` Mart van de Wege

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox