zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Model/Core/MultiMapComponent.cs

49 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* 封装MultiMap用于重用
*/
namespace ET
{
public class MultiMapComponent<T, K>: Entity
{
public MultiMap<T, K> MultiMap = new MultiMap<T, K>();
public override void Dispose()
{
if (this.IsDisposed)
{
return;
}
base.Dispose();
this.MultiMap.Clear();
}
} public class UnOrderMultiMapComponent<T, K>: Object
{
private bool isDispose;
public UnOrderMultiMap<T, K> MultiMap = new UnOrderMultiMap<T, K>();
public static UnOrderMultiMapComponent<T, K> Create()
{
UnOrderMultiMapComponent<T, K> listComponent = ObjectPool.Instance.Fetch<UnOrderMultiMapComponent<T, K>>();
listComponent.isDispose = false;
return listComponent;
}
public override void Dispose()
{
if (this.isDispose)
{
return;
}
this.isDispose = true;
base.Dispose();
this.MultiMap.Clear();
ObjectPool.Instance.Recycle(this);
}
}
}