/// <summary> /// 移动顺序 两个参数的参考系都是源地址参考 序号越小越靠前 /// </summary> /// <param name="src">源地址</param> /// <param name="des">目的地址 正数为向上</param> /// <param name="relative">是否为相对寻址 </param> public void _Move(int src, int des, bool relative = false) { TEvent temp = m_list[src];//临时变量 用于交换 int tar = des; if (relative)//如果是相对寻址 { tar = src - des; } if (tar == src)//如果目标与源点是同一位置 { return; } if (tar > src)//如果目标在源点下方 { for (int i = src; i < tar; ++i) { m_list[i] = m_list[i + 1]; } m_list[tar] = temp; } else//如果目标在原点上方 { for (int i = src; i > tar; --i) { m_list[i] = m_list[i - 1]; } m_list[tar] = temp; } }
/// <summary> /// 扩容 /// </summary> private void _Expand() { int _length = m_list.Length; TEvent[] newList = new TEvent[_length + TEVENT_LIST_STEP]; for (int i = 0; i < _length; ++i) { newList[i] = m_list[i]; } m_list = newList; }
/// <summary> /// 添加 /// </summary> public void _Add(TEvent e) { ++m_length; if (length >= maxLength)//正常情况下是等于 { _Expand(); } m_list[length] = e; int temp = e.priority; e.priority = m_list[length - 1].priority;//TODO 优化 _Sort(length, temp); }