Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /charles/src/ai302/

charles
Discussion topic

Back to topic list

CVS update: /charles/src/ai302/

Reply

Author matthewjheaney
Full name Matthew Heaney
Date 2005-05-17 19:02:47 PDT
Message User: matthewjheaney
Date: 2005/05/17 19:02:47

Modified:
   charles/src/ai302/a-ciormu.adb

Log:
 replace_elem must be implemented in terms of unconditional insertion

File Changes:

Directory: /charles/src/ai302/
==============================

File [changed]: a-ciormu.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/ai302/a-​ciormu.adb?r1=1.8​&r2=1.9
Delta lines: +16 -51
---------------------
--- a-ciormu.adb 18 May 2005 01:35:15 -0000 1.8
+++ a-ciormu.adb 18 May 2005 02:02:45 -0000 1.9
@@ -631,65 +631,30 @@
          procedure Insert_Post is
             new Element_Keys.Generic​_Insert_Post (New_Node);
 
- procedure Insert is
- new Element_Keys.Generic​_Conditional_Insert (Insert_Post);
+ procedure Unconditional_Insert is
+ new Element_Keys.Generic​_Unconditional_Inser​t (Insert_Post);
 
          Result : Node_Access;
- Inserted : Boolean;
 
          X : Element_Access := Node.Element;
 
       begin -- Insert_New_Item
 
- begin
- Insert
+ Unconditional_Insert
               (Tree => Tree,
                Key => Item,
- Node => Result,
- Inserted => Inserted);
- exception
- when others =>
- Inserted := False; -- assignment failed
- end;
+ Node => Result);
+ --
+ -- NOTE:
+ -- If Insert fails, it's because the allocation/initialization
+ -- of the new value failed. The old element is still there,
+ -- so just let the exception propagate.
+ -- ENDNOTE.
 
- if Inserted then
             pragma Assert (Result = Node);
             Free_Element (X); -- OK if fails
- return;
- end if;
 
       end Insert_New_Item;
-
- Reinsert_Old_Element :
- declare
- function New_Node return Node_Access;
- pragma Inline (New_Node);
-
- function New_Node return Node_Access is
- begin
- return Node;
- end New_Node;
-
- procedure Insert_Post is
- new Element_Keys.Generic​_Insert_Post (New_Node);
-
- procedure Insert is
- new Element_Keys.Generic​_Conditional_Insert (Insert_Post);
-
- Result : Node_Access;
- Inserted : Boolean;
- begin
- Insert
- (Tree => Tree,
- Key => Node.Element.all,
- Node => Result,
- Inserted => Inserted);
- exception
- when others =>
- null; -- assignment must have failed
- end Reinsert_Old_Element;
-
- raise Program_Error;
 
    end Replace_Element;

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

Messages

Show all messages in topic

CVS update: /charles/src/ai302/ matthewjheaney Matthew Heaney 2005-05-17 19:02:47 PDT
Messages per page: