Example #1
0
 /// <summary>
 /// 数据合并,针对x相同的数据且y可连续的数据进行合并
 /// </summary>
 public void Combo()
 {
     if (fogMaskFixGroupY.Count >= 2)
     {
         fogMaskFixGroupY.Sort((l, r) => {
             return(l.beginY.CompareTo(r.beginY));
         });
         FogMaskFixGroupY beforePtr = null;
         FogMaskFixGroupY afterPtr  = null;
         for (int i = fogMaskFixGroupY.Count - 1; i > 0; i--)
         {
             beforePtr = fogMaskFixGroupY [i - 1];
             afterPtr  = fogMaskFixGroupY [i];
             /// 收尾相连则合并之
             if (beforePtr.endY + 1 == afterPtr.beginY)
             {
                 /// 扩展before的数组
                 beforePtr.colorArray.AddRange(afterPtr.colorArray);
                 beforePtr.endY = afterPtr.endY;
                 /// 删除after
                 FogMaskFixGroupY.Recover(afterPtr);
                 fogMaskFixGroupY.RemoveAt(i);
             }
         }
     }
 }
Example #2
0
 public void Clear()
 {
     for (int i = fogMaskFixGroupY.Count - 1; i >= 0; i--)
     {
         FogMaskFixGroupY.Recover(fogMaskFixGroupY [i]);
     }
     fogMaskFixGroupY.Clear();
 }
Example #3
0
 public static FogMaskFixGroupY Get(int y, Color color)
 {
     if (_poolY.Count > 0)
     {
         FogMaskFixGroupY tmp = _poolY.Dequeue();
         tmp._SetYColor(y, color);
         return(tmp);
     }
     else
     {
         return(new FogMaskFixGroupY(y, color));
     }
 }
Example #4
0
        public void Add(int y, Color color)
        {
            bool             addSuccess = false;
            FogMaskFixGroupY ptr        = null;

            for (int i = 0, imax = fogMaskFixGroupY.Count; i < imax; i++)
            {
                ptr = fogMaskFixGroupY [i];
                if (ptr.endY + 1 == y)
                {
                    ptr.endY += 1;
                    ptr.AddAfter(color);
                    addSuccess = true;
                    break;
                }
            }
            if (!addSuccess)
            {
                ptr = FogMaskFixGroupY.Get(y, color);
                fogMaskFixGroupY.Add(ptr);
            }
        }
Example #5
0
 public static void Recover(FogMaskFixGroupY item)
 {
     item.colorArray.Clear();
     _poolY.Enqueue(item);
 }