/// <summary> /// 通过[大类]二分快速查表 /// </summary> /// <param name="firID">大类</param> /// <returns></returns> public static IEnumerable <BibleDataBase> Query(this List <BibleDataBase> sorted, uint firID) { var key = new BibleDataBase() { firID = firID }; var comparer = new Comparer1(); var from = sorted.BinarySearch(key, comparer); if (from < 0) { yield break; } var to = from + 1; while (from > 0 && comparer.Compare(key, sorted[from - 1]) == 0) { from--; } while (to < sorted.Count && comparer.Compare(key, sorted[to]) == 0) { to++; } for (var i = from; i < to; i++) { yield return(sorted[i]); } }
/// <summary> /// 通过[大类 + 小类]二分快速查表 /// </summary> /// <param name="firID">大类</param> /// <param name="secID">小类</param> /// <returns></returns> public static BibleDataBase Query(this List <BibleDataBase> sorted, uint firID, uint secID) { var key = new BibleDataBase() { firID = firID, secID = secID }; var comparer = new Comparer2(); var index = sorted.BinarySearch(key, comparer); return(index >= 0 ? sorted[index] : default(BibleDataBase)); }
private void SetSelectSecondType(uint type, bool force = false) { if (null == mSecondTabCreator) { return; } if (m_uint_activeStype == type && !force) { return; } UISecondTypeGrid sGrid = null; if (m_uint_activeFType != 0) { sGrid = mSecondTabCreator.GetGrid <UISecondTypeGrid>(mlstFirstTabIds.IndexOf(m_uint_activeFType), m_dic[m_uint_activeFType].IndexOf(m_uint_activeStype)); if (null != sGrid) { sGrid.SetHightLight(false); } } m_uint_activeStype = type; if (m_uint_activeFType != 0) { sGrid = mSecondTabCreator.GetGrid <UISecondTypeGrid>(mlstFirstTabIds.IndexOf(m_uint_activeFType), m_dic[m_uint_activeFType].IndexOf(m_uint_activeStype)); if (null != sGrid) { sGrid.SetHightLight(true); } } m_UIXmlRichText.Clear(); BibleDataBase table = GameTableManager.Instance.GetTableItem <BibleDataBase>(m_uint_activeFType, (int)m_uint_activeStype); if (table == null) { Engine.Utility.Log.Warning("华夏宝典表格大类{0}-小类{1}数据为空!", m_uint_activeFType, m_uint_activeStype); return; } string content = table.content; m_UIXmlRichText.AddXml(RichXmlHelper.RichXmlAdapt(content)); }