A game about forced loneliness, made by TACStudios
at master 1.6 kB view raw
1using System.Collections.Generic; 2using System.Linq; 3 4namespace Unity.PlasticSCM.Editor.UI.Tree 5{ 6 internal class TreeViewItemIds<C, I> 7 { 8 internal void Clear() 9 { 10 mCacheByCategories.Clear(); 11 mCacheByInfo.Clear(); 12 } 13 14 internal List<int> GetCategoryIds() 15 { 16 return new List<int>(mCacheByCategories.Values); 17 } 18 19 internal List<KeyValuePair<C, int>> GetCategoryItems() 20 { 21 return mCacheByCategories.ToList(); 22 } 23 24 internal List<KeyValuePair<I, int>> GetInfoItems() 25 { 26 return mCacheByInfo.ToList(); 27 } 28 29 internal bool TryGetCategoryItemId(C category, out int itemId) 30 { 31 return mCacheByCategories.TryGetValue(category, out itemId); 32 } 33 34 internal bool TryGetInfoItemId(I info, out int itemId) 35 { 36 return mCacheByInfo.TryGetValue(info, out itemId); 37 } 38 39 internal int AddCategoryItem(C category) 40 { 41 int itemId = GetNextItemId(); 42 43 mCacheByCategories.Add(category, itemId); 44 45 return itemId; 46 } 47 48 internal int AddInfoItem(I info) 49 { 50 int itemId = GetNextItemId(); 51 52 mCacheByInfo.Add(info, itemId); 53 54 return itemId; 55 } 56 57 int GetNextItemId() 58 { 59 return mCacheByCategories.Count 60 + mCacheByInfo.Count 61 + 1; 62 } 63 64 Dictionary<C, int> mCacheByCategories = new Dictionary<C, int>(); 65 Dictionary<I, int> mCacheByInfo = new Dictionary<I, int>(); 66 } 67}