Exemple #1
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 #2
0
        public VirtualIndex Clone()
        {
            VirtualIndex clone = new VirtualIndex();

            clone.x = x;
            clone.y = y;
            return(clone);
        }
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)
                    {
                        //if (count - accomdateble >= 0)
                        //    dstArr = new byte[maxSize];
                        //else
                        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 static void CopyData(VirtualArray src, VirtualIndex srcIndex, VirtualArray dst, VirtualIndex dstIndex, int count)
 {
     CopyData(src, srcIndex, dst, dstIndex, count, false);
 }
Exemple #5
0
 public void SetValueAt(VirtualIndex vIndex, byte value)
 {
     byte[] arr = _baseArray[vIndex.YIndex] as byte[];
     arr[vIndex.XIndex] = value;
 }
Exemple #6
0
 public byte GetValueAt(VirtualIndex vIndex)
 {
     byte[] arr = _baseArray[vIndex.YIndex] as byte[];
     return((byte)arr[vIndex.XIndex]);
 }