Mercurial > hg > ucis.core
changeset 19:b9ef273964fd
Updated ArrayUtil
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Wed, 10 Apr 2013 01:34:05 +0200 |
parents | a6faa87767bb |
children | c873e3dd73fe |
files | Util/ArrayUtil.cs |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Util/ArrayUtil.cs Wed Apr 10 01:33:54 2013 +0200 +++ b/Util/ArrayUtil.cs Wed Apr 10 01:34:05 2013 +0200 @@ -92,6 +92,26 @@ foreach (T v in array) h ^= v.GetHashCode(); return h; } + public static void Add<T>(ref T[] array, params T[] items) { + if (array == null) { + array = new T[items.Length]; + items.CopyTo(array, 0); + } else { + int index = array.Length; + Array.Resize(ref array, index + items.Length); + items.CopyTo(array, index); + } + } + public static void Add<T>(ref T[] array, ICollection<T> items) { + if (array == null) { + array = new T[items.Count]; + items.CopyTo(array, 0); + } else { + int index = array.Length; + Array.Resize(ref array, index + items.Count); + items.CopyTo(array, index); + } + } public static void Add<T>(ref T[] array, T item) { if (array == null) { array = new T[] { item };