Пример #1
0
 public SFormsFastMapDirect(SFormsFastMapDirect map)
 {
     for (int i = 2; i >= 0; i--)
     {
         FastSparseSetFactory <int> .FastSparseSet <int>[] arr = map.elements[i];
         int[] arrnext = map.next[i];
         int   length  = arr.Length;
         FastSparseSetFactory <int> .FastSparseSet <int>[] arrnew = new FastSparseSetFactory <int> .FastSparseSet <int>
                                                                    [length];
         int[] arrnextnew = new int[length];
         System.Array.Copy(arr, 0, arrnew, 0, length);
         System.Array.Copy(arrnext, 0, arrnextnew, 0, length);
         elements[i] = arrnew;
         next[i]     = arrnextnew;
         size__      = map.Size();
     }
 }
Пример #2
0
        public virtual SFormsFastMapDirect GetCopy()
        {
            SFormsFastMapDirect map = new SFormsFastMapDirect(false);

            map.size__ = size__;
            FastSparseSetFactory <int> .FastSparseSet <int>[][] mapelements = map.elements;
            int[][] mapnext = map.next;
            for (int i = 2; i >= 0; i--)
            {
                FastSparseSetFactory <int> .FastSparseSet <int>[] arr = elements[i];
                int length = arr.Length;
                if (length > 0)
                {
                    int[] arrnext = next[i];
                    FastSparseSetFactory <int> .FastSparseSet <int>[] arrnew = new FastSparseSetFactory <int> .FastSparseSet <int>
                                                                               [length];
                    int[] arrnextnew = new int[length];
                    System.Array.Copy(arrnext, 0, arrnextnew, 0, length);
                    mapelements[i] = arrnew;
                    mapnext[i]     = arrnextnew;
                    int pointer = 0;
                    do
                    {
                        FastSparseSetFactory <int> .FastSparseSet <int> set = arr[pointer];
                        if (set != null)
                        {
                            arrnew[pointer] = set.GetCopy();
                        }
                        pointer = arrnext[pointer];
                    }while (pointer != 0);
                }
                else
                {
                    mapelements[i] = FastSparseSetFactory <int> .FastSparseSet <int> .Empty_Array;
                    mapnext[i]     = InterpreterUtil.Empty_Int_Array;
                }
            }
            return(map);
        }
Пример #3
0
 public virtual void Union(SFormsFastMapDirect map)
 {
     for (int i = 2; i >= 0; i--)
     {
         FastSparseSetFactory <int> .FastSparseSet <int>[] lstExtern = map.elements[i];
         if (lstExtern.Length == 0)
         {
             continue;
         }
         FastSparseSetFactory <int> .FastSparseSet <int>[] lstOwn = elements[i];
         int[] arrnext       = next[i];
         int[] arrnextExtern = map.next[i];
         int   pointer       = 0;
         do
         {
             if (pointer >= lstOwn.Length)
             {
                 lstOwn  = EnsureCapacity(i, lstExtern.Length, true);
                 arrnext = next[i];
             }
             FastSparseSetFactory <int> .FastSparseSet <int> second = lstExtern[pointer];
             if (second != null)
             {
                 FastSparseSetFactory <int> .FastSparseSet <int> first = lstOwn[pointer];
                 if (first == null)
                 {
                     lstOwn[pointer] = second.GetCopy();
                     size__++;
                     ChangeNext(arrnext, pointer, arrnext[pointer], pointer);
                 }
                 else
                 {
                     first.Union(second);
                 }
             }
             pointer = arrnextExtern[pointer];
         }while (pointer != 0);
     }
 }
Пример #4
0
 public virtual void Intersection(SFormsFastMapDirect map)
 {
     for (int i = 2; i >= 0; i--)
     {
         FastSparseSetFactory <int> .FastSparseSet <int>[] lstOwn = elements[i];
         if (lstOwn.Length == 0)
         {
             continue;
         }
         FastSparseSetFactory <int> .FastSparseSet <int>[] lstExtern = map.elements[i];
         int[] arrnext = next[i];
         int   pointer = 0;
         do
         {
             FastSparseSetFactory <int> .FastSparseSet <int> first = lstOwn[pointer];
             if (first != null)
             {
                 FastSparseSetFactory <int> .FastSparseSet <int> second = null;
                 if (pointer < lstExtern.Length)
                 {
                     second = lstExtern[pointer];
                 }
                 if (second != null)
                 {
                     first.Intersection(second);
                 }
                 if (second == null || first.IsEmpty())
                 {
                     lstOwn[pointer] = null;
                     size__--;
                     ChangeNext(arrnext, pointer, pointer, arrnext[pointer]);
                 }
             }
             pointer = arrnext[pointer];
         }while (pointer != 0);
     }
 }