public void Put(IRecyclable x) { if (x.GetType() != m_Type) throw new ArgumentException(); lock (m_Stack) if (!m_Stack.Contains(x)) m_Stack.Push(x); }
public void Put(IRecyclable x) { if (x.GetType() != m_Type) { throw new ArgumentException(); } lock (m_Stack) if (!m_Stack.Contains(x)) { m_Stack.Push(x); } }
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 <IRecyclable> stack; if (!this.m_ReusableStacks.TryGetValue(type, out stack)) { stack = new Stack <IRecyclable>(); this.m_ReusableStacks.Add(type, stack); } recyclable.isTrashed = true; recyclable.OnTrash(); if (stack.Count < 500) { stack.Push(recyclable); } }