示例#1
0
        public static double?[] ToNullable(this double[] sourceArray, bool[] nullMask)
        {
            ThrowUtils.ThrowIf_True(nullMask.Length != sourceArray.Length, "Cannot convert to nullable array because nullMask.Length != sourceArray.Length");

            double?[] nullableArray = new double?[sourceArray.Length];
            for (int i = 0; i < nullableArray.Length; i++)
            {
                nullableArray[i] = nullMask[i] ? null : (double?)sourceArray[i];
            }

            return(nullableArray);
        }
示例#2
0
        public static List <T> Merge <T>(Func <T[], T> mergeFunc, params IList <T>[] collections)
        {
            if (collections.Length == 0)
            {
                return(new List <T>());
            }
            int count = collections[0].Count;

            ThrowUtils.ThrowIf_True(collections.Any(c => c.Count != count));

            T[]      tmp    = new T[collections.Length];
            List <T> result = new List <T>(count);

            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < collections.Length; j++)
                {
                    tmp[j] = collections[j][i];
                }
                result.Add(mergeFunc(tmp));
            }

            return(result);
        }