Login | Register
My pages Projects Community openCollabNet

Discussions > issues > Re: Question about Delete (fwd message from Matthew Heaney)

charles
Discussion topic

Back to topic list

Re: Question about Delete (fwd message from Matthew Heaney)

Reply

Author Dmitriy Anisimkov <anisimkov at omsknet dot ru>
Full name Dmitriy Anisimkov <anisimkov at omsknet dot ru>
Date 2004-05-20 22:33:16 PDT
Message Pascal Obry wrote:

> If Position equals No_Element, this operation has no effect.
> Otherwise, Delete removes the node from the map and deallocates the
> node. Position is set to No_Element on return.

<<The reason for this behavior is that computing the successor of an
element is not an O(1) operation. >>

Matthew,

Delete by cursor in AI302.Containers.Ind​efinite_Hashed_Maps (in AWS/include)
is an O(1) operation because we have a Next pointer in the Node_Type.

   type Node_Type is
      record -- make this limited in Ada 0Y
         Key : Key_Access;
         Element : Element_Access;
         Next : Node_Access;
      end record;

But Delete always return No_Element in cursor.

-----------------------
   procedure Delete (Container : in out Map;
                     Position : in out Cursor) is
   begin

      if Position.Container = null then
         return;
      end if;

      if Position.Node = null then
         return;
      end if;

      pragma Assert (Position.Container =
                       Map_Access'(Containe​r'Unchecked_Access))​;

      Delete (Container.HT, Position.Node);

      Position := No_Element;

   end Delete;
----------------------

......

> Note that in the case of the list container, Delete really does return
> the successor of the node deleted.


Same interface have a different behaviour on different containers.
I think it is bad practice for common interfaces.
We know that different containers could have a different speed on the
same operations,
but i think users expect to have at least the same behavior on the same
routines.

If user want to delete fast, without choose next element they could
choose different delete operation.

Moreover there is no reson to have "in out" parameter mode for Cursor in
delete statement,
because we would have No_Element every time.


--------------------​--------------------​--------------------​---------
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 4 | Next message in topic »

Messages

Show all messages in topic

Re: Question about Delete (fwd message from Matthew Heaney) Dmitriy Anisimkov <anisimkov at omsknet dot ru> Dmitriy Anisimkov <anisimkov at omsknet dot ru> 2004-05-20 22:33:16 PDT
     Re: Question about Delete (fwd message from Matthew Heaney) Pascal Obry <pascal at obry dot org> Pascal Obry <pascal at obry dot org> 2004-05-20 22:54:07 PDT
         RE: Question about Delete (fwd message from Matthew Heaney) matthewjheaney Matthew Heaney 2004-05-21 06:38:35 PDT
     RE: Question about Delete (fwd message from Matthew Heaney) matthewjheaney Matthew Heaney 2004-05-21 06:33:27 PDT
Messages per page: