Exemplo n.º 1
0
        /// <summary>
        /// 插入一条。插入正确的位置。不考虑重合的情况
        /// </summary>
        /// <param name="unit"></param>
        public void Insert(RleUnit unit)
        {
            int count = listSort.Count;

            if (count == 0)
            {
                listSort.Add(unit);
            }
            else if (count == 1)
            {
                if (unit <= listSort[0])
                {
                    listSort.Insert(0, unit);
                }
                else
                {
                    listSort.Add(unit);
                }
            }
            else
            {
                int low  = 0;
                int high = count - 1;
                do
                {
                    if (unit <= listSort[low])
                    {
                        listSort.Insert(low, unit);
                        break;
                    }
                    else if (listSort[high] <= unit)
                    {
                        listSort.Insert(high + 1, unit);
                        break;
                    }
                    else
                    {
                        int middle = (low + high) / 2;
                        if (unit <= listSort[middle])
                        {
                            high = middle;
                        }
                        else
                        {
                            low = middle;
                        }
                    }
                }while (low <= high);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            RleUnit p = (RleUnit)obj;

            if ((System.Object)p == null)
            {
                return(false);
            }
            return((start == p.start) && (end == p.end));
        }
Exemplo n.º 3
0
 /// <summary>
 /// 移除
 /// </summary>
 /// <param name="unit"></param>
 public void Remove(RleUnit unit)
 {
     listSort.Remove(unit);
 }