Exemple #1
0
 public VirtualIndex Clone()
 {
     VirtualIndex clone = new VirtualIndex();
     clone.x = x;
     clone.y = y;
     return clone;
 }
Exemple #2
0
        public int CompareTo(object obj)
        {
            VirtualIndex other = null;

            if (obj is VirtualIndex)
            {
                other = obj as VirtualIndex;
            }
            else if (obj is int)
            {
                other = new VirtualIndex((int)obj);
            }
            else
            {
                return(-1);
            }

            if (other.IndexValue == IndexValue)
            {
                return(0);
            }
            else if (other.IndexValue > IndexValue)
            {
                return(-1);
            }
            else
            {
                return(1);
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        public VirtualIndex Clone()
        {
            VirtualIndex clone = new VirtualIndex();

            clone.x = x;
            clone.y = y;
            return(clone);
        }
Exemple #5
0
        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);
            }
        }
Exemple #6
0
        public int CompareTo(object obj)
        {
            VirtualIndex other = null;
            if (obj is VirtualIndex)
                other = obj as VirtualIndex;
            else if (obj is int)
                other = new VirtualIndex((int)obj);
            else
                return -1;

            if (other.IndexValue == IndexValue)
                return 0;
            else if (other.IndexValue > IndexValue)
                return -1;
            else
                return 1;
        }
Exemple #7
0
 public static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count)
 {
     CopyData(src, srcIndex, dst, dstIndex, count, false);
 }
Exemple #8
0
 public void SetValueAt(VirtualIndex vIndex, byte value)
 {
     byte[] arr = _baseArray[vIndex.YIndex] as byte[];
     arr[vIndex.XIndex] = value;
 }
Exemple #9
0
 public byte GetValueAt(VirtualIndex vIndex)
 {
     byte[] arr = _baseArray[vIndex.YIndex] as byte[];
     return((byte)arr[vIndex.XIndex]);
 }
        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;
        }
Exemple #11
0
 public static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count)
 {
     CopyData(src, srcIndex, dst, dstIndex, count, false);
 }
Exemple #12
0
 public void SetValueAt(VirtualIndex vIndex,byte value)
 {
     byte[] arr = _baseArray[vIndex.YIndex] as byte[];
     arr[vIndex.XIndex] = value;
 }
Exemple #13
0
 public byte GetValueAt(VirtualIndex vIndex)
 {
     byte[] arr = _baseArray[vIndex.YIndex] as byte[];
     return (byte) arr[vIndex.XIndex];
 }