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 2004-03-22 19:52:36 PST
Message User: matthewjheaney
Date: 04/03/22 19:52:36

Modified:
 /charles/src/ai302/
  ai302-containers-vectors.adb

Log:
 added assign operation
 swap op is now move

File Changes:

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

File [changed]: ai302-containers-vectors.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/ai302/ai​302-containers-vecto​rs.adb?r1=1.3&r2​=1.4
Delta lines: +44 -8
--------------------
--- ai302-containers-vectors.adb 23 Mar 2004 02:57:46 -0000 1.3
+++ ai302-containers-vectors.adb 23 Mar 2004 03:52:33 -0000 1.4
@@ -252,20 +252,56 @@
    end;
 
 
- procedure Swap (Left, Right : in out Vector) is
+ procedure Assign
+ (Target : in out Vector;
+ Source : in Vector) is
 
- LE : constant Elements_Access := Left.Elements;
- LL : constant Index_Type'Base := Left.Last;
+ N : constant Size_Type := Length (Source);
 
    begin
 
- Left.Elements := Right.Elements;
- Left.Last := Right.Last;
+ if Target'Address = Source'Address then
+ return;
+ end if;
 
- Right.Elements := LE;
- Right.Last := LL;
+ if Size (Target) < N then
+ Target.Last := Index_Type'Pred (Index_Type'First);
+ Resize (Target, Size => N);
+ end if;
 
- end Swap;
+ Target.Last := Source.Last;
+
+ if N > 0 then
+ Target.Elements (Index_Type'First .. Target.Last) :=
+ Source.Elements (Index_Type'First .. Source.Last);
+ end if;
+
+ end Assign;
+
+
+ procedure Move
+ (Target : in out Vector;
+ Source : in out Vector) is
+
+ TE : constant Elements_Access := Target.Elements;
+
+ begin
+
+ if Target'Address = Source'Address then
+ return;
+ end if;
+
+ if Target.Last >= Index_Type'First then
+ raise Constraint_Error;
+ end if;
+
+ Target.Elements := Source.Elements;
+ Target.Last := Source.Last;
+
+ Source.Elements := TE; --?
+ Source.Last := Index_Type'Pred (Index_Type'First);
+
+ end Move;
 
 
    procedure Append (Container : in out Vector;




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@char​les.tigris.org
For additional commands, e-mail: cvs-help at charles dot tigris dot org

« 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 2004-03-22 19:52:36 PST
Messages per page: