comp.lang.ada
 help / color / mirror / Atom feed
From: "Frank" <franjoe@frisurf.no>
Subject: Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p
Date: 13 Mar 2003 11:16:25 +0100
Date: 2003-03-13T11:16:25+01:00	[thread overview]
Message-ID: <3e705a78$1@news.wineasy.se> (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









             reply	other threads:[~2003-03-13 10:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-13 10:16 Frank [this message]
2003-03-13 14:51 ` Using Grace.Lists.Unbounded in WindowsXP/GNAT3.15p Stephen Leake
2003-03-13 15:56   ` Frank
2003-03-13 16:26 ` Matthew Heaney
replies disabled

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