comp.lang.ada
 help / color / mirror / Atom feed
* Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p
@ 2003-03-13 10:16 Frank
  2003-03-13 14:51 ` Stephen Leake
  2003-03-13 16:26 ` Matthew Heaney
  0 siblings, 2 replies; 4+ messages in thread
From: Frank @ 2003-03-13 10:16 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2379 bytes --]


Hi!

Using WindowsXP/GNAT3.15p/Grace.Lists "1.1".

See source code and execution-dump at the end.

1)
In this example I add a number of nodes to a list, and traverse them
successfully to
print their contence.

2)
I traverse the list until the second node.
Then I try to remove the second Node.
The library now throws me a CONSTRAINT_ERROR.


Where am I mistaking?


----

The big picture(but not fully coded in this example):
What I want to achieve is to be able to traverse a list, and based on
information in the
node, decide to remove it from the current position in the list and reinsert
it at the end.
This is done to postpone the calculation of the Node until all other Nodes
have been calculated.


Frank J�rgensen


------------------------------------------------
with Grace.Lists.Unbounded;
with Test_List_Pkg;
with Ada.Text_IO;

procedure Test_List is

  Allowed_Nodes : Test_List_Pkg.Test_Nodes.List :=
Test_List_Pkg.Test_Nodes.Empty;
  Tmp_Trav : Test_List_Pkg.Test_Nodes.Iterator;
  Tmp_Data : Integer;
begin

  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 1,
Test_List_Pkg.Test_Nodes.Tail);
  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 2,
Test_List_Pkg.Test_Nodes.Tail);
  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 3,
Test_List_Pkg.Test_Nodes.Tail);
  Test_List_Pkg.Test_Nodes.Insert (Allowed_Nodes, 4,
Test_List_Pkg.Test_Nodes.Tail);

  Tmp_Trav := Test_List_Pkg.Test_Nodes.Head(Allowed_Nodes);

  while Test_List_Pkg.Test_Nodes.Has_Item(Tmp_Trav)  loop
    Tmp_Data := Test_List_Pkg.Test_Nodes.Item(Tmp_Trav);


    Ada.Text_IO.Put_Line("---" & Tmp_Data'Img);
    Tmp_Trav := Test_List_Pkg.Test_Nodes.Next(Tmp_Trav,
Test_List_Pkg.Test_Nodes.Tail);
  end loop;

  Tmp_Trav := Test_List_Pkg.Test_Nodes.Head(Allowed_Nodes);
  Tmp_Trav := Test_List_Pkg.Test_Nodes.Next(Tmp_Trav,
Test_List_Pkg.Test_Nodes.Tail);

  Test_List_Pkg.Test_Nodes.Remove (Tmp_Trav, Test_List_Pkg.Test_Nodes.Tail);

end Test_List;

------------------------------------------------
with Grace.Lists.Unbounded;

package Test_List_Pkg is
  package Test_Nodes is new Grace.Lists.Unbounded (Integer);
end Test_List_Pkg;

------------------------------------------------
--- 1
--- 2
--- 3
--- 4
ERROR: After finalization of Empty object,  6 items have been allocated
and  5 items have been freed.

raised CONSTRAINT_ERROR : grace-lists-unbounded.adb:70 access check failed









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

end of thread, other threads:[~2003-03-13 16:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-13 10:16 Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p Frank
2003-03-13 14:51 ` Stephen Leake
2003-03-13 15:56   ` Frank
2003-03-13 16:26 ` Matthew Heaney

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