/// <summary> /// 通过[大类ID]二分快速查表 /// </summary> /// <param name="ID">大类ID</param> /// <returns></returns> public static IEnumerable <ConsignmentCateIDConf> Query(this List <ConsignmentCateIDConf> sorted, uint ID) { var key = new ConsignmentCateIDConf() { ID = ID }; 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> /// 通过[大类ID + 细类ID]二分快速查表 /// </summary> /// <param name="ID">大类ID</param> /// <param name="SubID">细类ID</param> /// <returns></returns> public static ConsignmentCateIDConf Query(this List <ConsignmentCateIDConf> sorted, uint ID, uint SubID) { var key = new ConsignmentCateIDConf() { ID = ID, SubID = SubID }; var comparer = new Comparer2(); var index = sorted.BinarySearch(key, comparer); return(index >= 0 ? sorted[index] : default(ConsignmentCateIDConf)); }
/// <summary> /// 设置寄售物品分类数据 /// </summary> public void SetConsignmentList() { if (m_cateIdConfigList.Count > 0) { return; } List <ConsignmentCateIDConf> dataList = GameTableManager.Instance.GetTableList <ConsignmentCateIDConf>(); if (null == dataList) { Engine.Utility.Log.Error("ConsignmentCateIDConf is null"); return; } for (int i = 0; i < dataList.Count; i++) { ConsignmentCateIDConf item = dataList[i]; if (null != item) { uint iD = item.ID; if (!m_subCateIdConfigDic.ContainsKey(iD)) { m_cateIdConfigList.Add(item); } List <ConsignmentCateIDConf> list = null; if (m_subCateIdConfigDic.TryGetValue(iD, out list)) { if (list != null) { list.Add(item); } } else { list = new List <ConsignmentCateIDConf> { item }; this.m_subCateIdConfigDic.Add(iD, list); } } } //清空一下“我的关注”的二级页签 if (m_subCateIdConfigDic.ContainsKey(0)) { m_subCateIdConfigDic[0].Clear(); } m_filterConfigList = GameTableManager.Instance.GetTableList <ConsignmentFilterConf>(); m_CanSellItemList = GameTableManager.Instance.GetTableList <ConsignmentCanSellItem>(); }