OSDN Git Service

InsertRangeメソッドを追加した
authorgdkhd812 <jbh03215@htmil.co.jp>
Sun, 29 Sep 2013 20:19:23 +0000 (05:19 +0900)
committergdkhd812 <jbh03215@htmil.co.jp>
Sun, 29 Sep 2013 20:19:23 +0000 (05:19 +0900)
Common/GapBuffer.cs
WPF/FooEditEngine.sln

index b27241a..2161aeb 100644 (file)
@@ -456,6 +456,43 @@ namespace Slusser.Collections.Generic
                }
 
 
+        /// <summary>
+        /// Inserts the elements of a collection into the <see cref="GapBuffer{T}"/> at the specified index. 
+        /// Consecutive operations at or near previous inserts are optimized.
+        /// </summary>
+        /// <param name="index">The zero-based index at which the new elements should be inserted.</param>
+        /// <param name="col">The collection whose elements should be inserted into the <see cref="GapBuffer{T}"/>. 
+        /// The collection itself cannot be null, but it can contain elements that are null, if 
+        /// type <typeparamref name="T"/> is a reference type.</param>
+        /// <exception cref="ArgumentNullException"><paramref name="collection"/> is a null reference.</exception>
+        /// <exception cref="ArgumentOutOfRangeException">
+        /// <paramref name="index"/> is less than 0.
+        /// <para>-or-</para>
+        /// <paramref name="index"/> is greater than <see cref="Count"/>.
+        /// </exception>
+        public void InsertRange(int index, ICollection<T> col)
+        {
+            if (col == null)
+                throw new ArgumentNullException("collection");
+
+            if (index < 0 || index > Count)
+                throw new ArgumentOutOfRangeException("index", "");
+
+            if (col != null)
+            {
+                int count = col.Count;
+                if (count > 0)
+                {
+                    PlaceGapStart(index);
+                    EnsureGapCapacity(count);
+
+                    // Copy the collection directly into the buffer
+                    col.CopyTo(this._buffer, this._gapStart);
+                    this._gapStart += count;
+                }
+            }
+            this._version++;
+        }
                /// <summary>
                /// Inserts the elements of a collection into the <see cref="GapBuffer{T}"/> at the specified index. 
                /// Consecutive operations at or near previous inserts are optimized.
@@ -479,21 +516,7 @@ namespace Slusser.Collections.Generic
             if (index < 0 || index > Count)
                 throw new ArgumentOutOfRangeException("index", "");
 
-            ICollection<T> col = collection as ICollection<T>;
-            if (col != null)
-            {
-                int count = col.Count;
-                if (count > 0)
-                {
-                    PlaceGapStart(index);
-                    EnsureGapCapacity(count);
-
-                    // Copy the collection directly into the buffer
-                    col.CopyTo(this._buffer, this._gapStart);
-                    this._gapStart += count;
-                }
-            } 
-            else if (collectionCount == -1)
+            if (collectionCount == -1)
             {
                 // Add the items to the buffer one-at-a-time :(
                 using (IEnumerator<T> enumerator = collection.GetEnumerator())
index 9add92e..bafbfd1 100644 (file)
@@ -63,4 +63,7 @@ Global
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
        EndGlobalSection
+       GlobalSection(Performance) = preSolution
+               HasPerformanceSessions = true
+       EndGlobalSection
 EndGlobal