public static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count, bool allowExpantion) { if (src == null || dst == null || srcIndex == null || dstIndex == null) { return; } if (src.Size < srcIndex.IndexValue) { throw new IndexOutOfRangeException(); } srcIndex = srcIndex.Clone(); dstIndex = dstIndex.Clone(); while (count > 0) { Array arr = src._baseArray[srcIndex.YIndex] as Array; int copyCount = maxSize - srcIndex.XIndex; if (copyCount > count) { copyCount = count; } Array dstArr = null; if (dst._baseArray.Count > dstIndex.YIndex) { dstArr = dst._baseArray[dstIndex.YIndex] as Array; } int accomdateble = (maxSize - dstIndex.XIndex); if (accomdateble > copyCount) { accomdateble = copyCount; } if ((dstArr == null || accomdateble > (dstArr.Length - dstIndex.XIndex)) && allowExpantion) { if (dstArr == null) { dstArr = new byte[accomdateble]; dst._baseArray.Add(dstArr); } else { byte[] tmpArray = new byte[accomdateble + dstArr.Length - (dstArr.Length - dstIndex.XIndex)]; Buffer.BlockCopy(dstArr, 0, tmpArray, 0, dstArr.Length); dstArr = tmpArray; dst._baseArray[dstIndex.YIndex] = dstArr; } } Buffer.BlockCopy(arr, srcIndex.XIndex, dstArr, dstIndex.XIndex, accomdateble); count -= accomdateble; srcIndex.IncrementBy(accomdateble); dstIndex.IncrementBy(accomdateble); } }
public static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count,bool allowExpantion) { if (src == null || dst == null || srcIndex == null || dstIndex == null) return; if (src.Size < srcIndex.IndexValue) throw new IndexOutOfRangeException(); srcIndex = srcIndex.Clone(); dstIndex = dstIndex.Clone(); while (count > 0) { Array arr = src._baseArray[srcIndex.YIndex] as Array; int copyCount = maxSize - srcIndex.XIndex; if (copyCount > count) { copyCount = count; } Array dstArr = null; if(dst._baseArray.Count >dstIndex.YIndex) dstArr= dst._baseArray[dstIndex.YIndex] as Array; int accomdateble = (maxSize - dstIndex.XIndex); if (accomdateble > copyCount) { accomdateble = copyCount; } if ((dstArr == null || accomdateble > (dstArr.Length -dstIndex.XIndex)) && allowExpantion) { if (dstArr == null) { dstArr = new byte[accomdateble]; dst._baseArray.Add(dstArr); } else { byte[] tmpArray = new byte[accomdateble + dstArr.Length - (dstArr.Length - dstIndex.XIndex)]; Buffer.BlockCopy(dstArr, 0, tmpArray, 0, dstArr.Length); dstArr = tmpArray; dst._baseArray[dstIndex.YIndex] = dstArr; } } Buffer.BlockCopy(arr, srcIndex.XIndex, dstArr, dstIndex.XIndex, accomdateble); count -= accomdateble; srcIndex.IncrementBy(accomdateble); dstIndex.IncrementBy(accomdateble); } }
public static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count) { CopyData(src, srcIndex, dst, dstIndex, count, false); }
protected static Hashtable GetAllPayLoads(Array userPayLoad, ArrayList compilationInfo) { Hashtable result = new Hashtable(); int arrayIndex = 0; int readIndex = 0; VirtualArray payLoadArray = new VirtualArray(userPayLoad); Alachisoft.NCache.Common.DataStructures.VirtualIndex virtualIndex = new Alachisoft.NCache.Common.DataStructures.VirtualIndex(); for (int i = 0; i < compilationInfo.Count; i++) { if ((long)compilationInfo[i] == 0) { result[i] = null; } else { VirtualArray atomicPayLoadArray = new VirtualArray((long)compilationInfo[i]); Alachisoft.NCache.Common.DataStructures.VirtualIndex atomicVirtualIndex = new Alachisoft.NCache.Common.DataStructures.VirtualIndex(); VirtualArray.CopyData(payLoadArray, virtualIndex, atomicPayLoadArray, atomicVirtualIndex, (int)atomicPayLoadArray.Size); virtualIndex.IncrementBy((int)atomicPayLoadArray.Size); result[i] = atomicPayLoadArray.BaseArray; } } return result; }