changeset 48:f553f6e0a396

ArrayUtil: added Merge function to merge ILists
author Ivo Smits <Ivo@UCIS.nl>
date Tue, 16 Jul 2013 14:02:33 +0200
parents 15ddb1e0e2a5
children 7e4dae99f919
files Util/ArrayUtil.cs
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Util/ArrayUtil.cs	Tue Jul 16 13:16:04 2013 +0200
+++ b/Util/ArrayUtil.cs	Tue Jul 16 14:02:33 2013 +0200
@@ -65,6 +65,17 @@
 			}
 			return ret;
 		}
+		public static T[] Merge<T>(params IList<T>[] parts) {
+			int count = 0;
+			foreach (IList<T> segment in parts) count += segment.Count;
+			T[] ret = new T[count];
+			int offset = 0;
+			foreach (IList<T> segment in parts) {
+				segment.CopyTo(ret, offset);
+				offset += segment.Count;
+			}
+			return ret;
+		}
 		public static Boolean Equal<T>(T[] a, T[] b, IEqualityComparer<T> comparer) {
 			if (ReferenceEquals(a, b)) return true;
 			if (a == null || b == null) return false;