private static BSDataObject ProcessWithoutArraySizeShrinkage(BSDataObject iObj, WindowBasedPreprocessor iProcessor) { double[] iArray = iObj.DataArray; double[] result = iProcessor.Process(iObj).DataArray; List <double> aList = new List <double>(); FieldInfo[] info = aList.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); //this stuff is here to make list from array without copying its elements info[0].SetValue(aList, result); //_items private field info[1].SetValue(aList, result.Count()); //_size private field aList.Capacity = result.Count() + iProcessor.WindowSize - 1; aList.InsertRange(0, iArray.Take((iProcessor.WindowSize - 1) / 2)); aList.AddRange(iArray.Skip(iArray.Count() - (iProcessor.WindowSize - 1) / 2)); result = (double[])info[0].GetValue(aList); return(new BSDataObject(result, iObj.ObjName)); }
private static BSDataObject ProcessWithoutArraySizeShrinkage(BSDataObject iObj, WindowBasedPreprocessor iProcessor) { double[] iArray = iObj.DataArray; double[] result = iProcessor.Process(iObj).DataArray; List<double> aList = new List<double>(); FieldInfo[] info = aList.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); //this stuff is here to make list from array without copying its elements info[0].SetValue(aList, result); //_items private field info[1].SetValue(aList, result.Count()); //_size private field aList.Capacity = result.Count() + iProcessor.WindowSize - 1; aList.InsertRange(0, iArray.Take((iProcessor.WindowSize - 1) / 2)); aList.AddRange(iArray.Skip(iArray.Count() - (iProcessor.WindowSize - 1) / 2)); result = (double[])info[0].GetValue(aList); return new BSDataObject(result, iObj.ObjName); }