Login | Register
My pages Projects Community openCollabNet

Discussions > issues > Question about Delete

charles
Discussion topic

Back to topic list

Question about Delete

Reply

Author Pascal Obry <pascal at obry dot org>
Full name Pascal Obry <pascal at obry dot org>
Date 2004-05-20 01:53:27 PDT
Message I have read in a document (maybe an old one) that Delete (Map, Cursor) should
return the next element in Cursor or No_Element if Cursor point to the last
element in the container.

The following program shows that this is not the case:

with AI302.Containers.Ind​efinite_Hashed_Maps;​
with AI302.Strings.Hash;

package Strings_Maps is

   package Containers is
     new AI302.Containers.Ind​efinite_Hashed_Maps
       (String, Integer, AI302.Strings.Hash, "=", "=");

end Strings_Maps;

with Ada.Text_IO;

with AI302.Containers;
with Strings_Maps;

procedure Test_Delete is

   use Ada.Text_IO;
   use AI302.Containers;
   use Strings_Maps.Containers;

   Hash : Map;
   C : Cursor;
   Success : Boolean;
begin
   Insert
     (Container => Hash,
      Key => "key1",
      New_Item => 1,
      Position => C,
      Success => Success);

   Insert
     (Container => Hash,
      Key => "key2",
      New_Item => 2,
      Position => C,
      Success => Success);

   if Length (Hash) /= 2 then
      Put_Line ("Number of items in Hash should be 2");
   end if;

   C := First (Hash);

   Delete (Hash, C);

   if C = No_Element then
      Put_Line ("Error, this should point to the next element");
   end if;

   Delete (Hash, C);

   if C /= No_Element then
      Put_Line ("Error, there is no more element, should be No_Element");
   end if;
end Test_Delete;

Can somebody clarify the proper semantic for Delete ? What is the very
last document about the AI302 ?

Thanks,
Pascal.

--

--|-----------------​--------------------​-----------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|-----------------​--------------------​-----------------
--| http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595


--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: issues-unsubscribe@c​harles.tigris.org
For additional commands, e-mail: issues-help at charles dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

Question about Delete Pascal Obry <pascal at obry dot org> Pascal Obry <pascal at obry dot org> 2004-05-20 01:53:27 PDT
Messages per page: