using System; using System.Collections.Generic; namespace UnityEngine.Experimental.UIElements { // Token: 0x0200033B RID: 827 internal class Recycler { // Token: 0x06003372 RID: 13170 RVA: 0x000506F4 File Offset: 0x0004E8F4 public void Trash(IRecyclable recyclable) { if (recyclable.isTrashed) { throw new ArgumentException("Trying to add an element to the Recycler more than once"); } Type type = recyclable.GetType(); Stack stack; if (!this.m_ReusableStacks.TryGetValue(type, out stack)) { stack = new Stack(); this.m_ReusableStacks.Add(type, stack); } recyclable.isTrashed = true; recyclable.OnTrash(); if (stack.Count < 500) { stack.Push(recyclable); } } // Token: 0x06003373 RID: 13171 RVA: 0x0005076C File Offset: 0x0004E96C public void Clear() { this.m_ReusableStacks.Clear(); } // Token: 0x17000BB2 RID: 2994 // (get) Token: 0x06003374 RID: 13172 RVA: 0x0005077C File Offset: 0x0004E97C public int Count { get { int num = 0; foreach (KeyValuePair> keyValuePair in this.m_ReusableStacks) { num += keyValuePair.Value.Count; } return num; } } // Token: 0x06003375 RID: 13173 RVA: 0x000507CC File Offset: 0x0004E9CC public TType TryReuse() where TType : IRecyclable { Type typeFromHandle = typeof(TType); TType ttype = default(TType); Stack stack; if (this.m_ReusableStacks.TryGetValue(typeFromHandle, out stack)) { if (stack.Count > 0) { ttype = (TType)((object)stack.Pop()); ttype.isTrashed = false; ttype.OnReuse(); } } return ttype; } // Token: 0x04000A97 RID: 2711 public const int MaxInstancesPerType = 500; // Token: 0x04000A98 RID: 2712 private Dictionary> m_ReusableStacks = new Dictionary>(); } }