using System.Collections.Generic; using System.Linq; namespace Unity.PlasticSCM.Editor.UI.Tree { internal class TreeViewItemIds { internal void Clear() { mCacheByCategories.Clear(); mCacheByInfo.Clear(); } internal List GetCategoryIds() { return new List(mCacheByCategories.Values); } internal List> GetCategoryItems() { return mCacheByCategories.ToList(); } internal List> GetInfoItems() { return mCacheByInfo.ToList(); } internal bool TryGetCategoryItemId(C category, out int itemId) { return mCacheByCategories.TryGetValue(category, out itemId); } internal bool TryGetInfoItemId(I info, out int itemId) { return mCacheByInfo.TryGetValue(info, out itemId); } internal int AddCategoryItem(C category) { int itemId = GetNextItemId(); mCacheByCategories.Add(category, itemId); return itemId; } internal int AddInfoItem(I info) { int itemId = GetNextItemId(); mCacheByInfo.Add(info, itemId); return itemId; } int GetNextItemId() { return mCacheByCategories.Count + mCacheByInfo.Count + 1; } Dictionary mCacheByCategories = new Dictionary(); Dictionary mCacheByInfo = new Dictionary(); } }