dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Collections/Ar...


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Collections/Ar...
Date: Wed, 18 Oct 2006 10:13:53 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Changes by:     Heiko Weiss <brubbel>   06/10/18 10:13:53

Modified files:
        .              : ChangeLog 
        runtime/System/Collections: ArrayList.cs 

Log message:
        fixed AddRange of self.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2442&r2=1.2443
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/Collections/ArrayList.cs?cvsroot=dotgnu-pnet&r1=1.21&r2=1.22

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2442
retrieving revision 1.2443
diff -u -b -r1.2442 -r1.2443
--- ChangeLog   18 Oct 2006 08:16:01 -0000      1.2442
+++ ChangeLog   18 Oct 2006 10:13:53 -0000      1.2443
@@ -1,5 +1,9 @@
 2006-10-18  Heiko Weiss <address@hidden>
 
+       * runtime/System/Collections/ArrayList.cs: fixed AddRange of self.
+
+2006-10-18  Heiko Weiss <address@hidden>
+
        * runtime/System/Double.cs: fixed formatting NaN and Infinity values.
 
 2006-10-17  Heiko Weiss <address@hidden>

Index: runtime/System/Collections/ArrayList.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/runtime/System/Collections/ArrayList.cs,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- runtime/System/Collections/ArrayList.cs     13 Apr 2006 15:18:08 -0000      
1.21
+++ runtime/System/Collections/ArrayList.cs     18 Oct 2006 10:13:53 -0000      
1.22
@@ -262,35 +262,13 @@
        // Add the contents of a collection as a range.
        public virtual void AddRange(ICollection c)
                        {
-                               int cCount;
-                               IEnumerator enumerator;
-                               if(c == null)
-                               {
-                                       throw new ArgumentNullException("c");
-                               }
-                               cCount = c.Count;
-                               if((count + cCount) > store.Length)
-                               {
-                                       Realloc(cCount, count);
-                               }
-                               enumerator = c.GetEnumerator();
-                               
-                               if(enumerator.MoveNext())
-                               {
-                                       ++generation;
-                                       do
-                                       {
-                                               store[count++] = 
enumerator.Current;
-                                       }
-                                       while(enumerator.MoveNext());
-                               }
+                               // use nsert range to ensure the SyncRoot check
+                               this.InsertRange( count, c );
                        }
 
        // Insert the contents of a collection as a range.
        public virtual void InsertRange(int index, ICollection c)
                        {
-                               int cCount;
-                               IEnumerator enumerator;
                                if(c == null)
                                {
                                        throw new ArgumentNullException("c");
@@ -300,25 +278,26 @@
                                        throw new ArgumentOutOfRangeException
                                                ("index", _("ArgRange_Array"));
                                }
-                               cCount = c.Count;
-                               Realloc(cCount, index);
-                               enumerator = c.GetEnumerator();
+                               int cCount = c.Count;
                                
-                               if(c.SyncRoot == this && (c is ICloneable))
+                               if( cCount > 0 ) {
+                                       if((count + cCount) > store.Length)
                                {
-                                       c = 
(ICollection)((ICloneable)c).Clone();
+                                               Realloc(cCount, count);
                                }
-                               
-                               if(enumerator.MoveNext())
-                               {
-                                       ++generation;
-                                       do
-                                       {
-                                               store[index++] = 
enumerator.Current;
+                                       if( index < this.count ) {
+                                               Array.Copy( this.store, index, 
this.store, index+cCount, this.count - index ); 
                                        }
-                                       while(enumerator.MoveNext());
+                                       if( c.SyncRoot == this.SyncRoot ) {
+                                               Array.Copy( this.store, 0, 
this.store, index, index );
+                                               Array.Copy( this.store, 
index+cCount, this.store, 2*index, this.count - index );
+                                       }
+                                       else {
+                                               c.CopyTo( this.store, index );
+                                       }
+                                       this.count += cCount;
+                                       ++generation;
                                }
-                               count += cCount;
                        }
 
        // Remove a range of elements from an array list.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]