using System; using System.Collections.Generic; namespace TyphoonUI { /// /// 池集合 /// public class ScrollCellPoolGroup { private Dictionary _pools = new Dictionary(); public Dictionary Pools => _pools; public ScrollCellPoolGroup() { } public void AddPool(string name, ScrollCellPool pool) { _pools.Add(name, pool); } //获取池 public ScrollCellPool GetPool(string poolName) { if (_pools.TryGetValue(poolName, out var match)) { return match; } throw new Exception($"未绑定池:{poolName}"); } //释放所有 public void Release() { foreach (var pair in _pools) { pair.Value.Release(); } _pools.Clear(); _pools = null; } //回收无效元素 public void RecycleInvalid(int startIndex, int endIndex, HashSet validIndex) { foreach (var pair in _pools) { pair.Value.RecycleInvalid(startIndex, endIndex, validIndex); } } //回收全部 public void RecycleAll() { foreach (var pair in _pools) { pair.Value.RecycleAll(); } } } }