From 98091d3e0aaab7c5a2287ca1981929130dc400d0 Mon Sep 17 00:00:00 2001 From: Makihiro Date: Fri, 29 Jan 2021 18:20:41 +0900 Subject: [PATCH] Update EmptyWeightedSelector.cs --- .../WeightedSelector/EmptyWeightedSelector.cs | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/Assets/MackySoft/MackySoft.Choice/Runtime/WeightedSelector/EmptyWeightedSelector.cs b/Assets/MackySoft/MackySoft.Choice/Runtime/WeightedSelector/EmptyWeightedSelector.cs index 56b87a5..39b1843 100644 --- a/Assets/MackySoft/MackySoft.Choice/Runtime/WeightedSelector/EmptyWeightedSelector.cs +++ b/Assets/MackySoft/MackySoft.Choice/Runtime/WeightedSelector/EmptyWeightedSelector.cs @@ -3,6 +3,7 @@ using System.Linq; namespace MackySoft.Choice { + internal sealed class EmptyWeightedSelector : IWeightedSelector { public static readonly EmptyWeightedSelector Instance = new EmptyWeightedSelector(); @@ -13,9 +14,9 @@ internal sealed class EmptyWeightedSelector : IWeightedSelector { public int Count => 0; - ICollection IDictionary.Keys => throw new System.NotImplementedException(); + ICollection IDictionary.Keys => EmptyCollection.Instance; - ICollection IDictionary.Values => throw new System.NotImplementedException(); + ICollection IDictionary.Values => EmptyCollection.Instance; bool ICollection>.IsReadOnly => false; @@ -70,5 +71,45 @@ public void CopyTo (KeyValuePair[] array,int arrayIndex) { public bool Remove (KeyValuePair item) { return false; } + + } + + internal sealed class EmptyCollection : ICollection { + + public static readonly EmptyCollection Instance = new EmptyCollection(); + + public int Count => 0; + + public bool IsReadOnly => false; + + public void Add (T item) { + + } + + public bool Remove (T item) { + return false; + } + + public void Clear () { + + } + + public bool Contains (T item) { + return false; + } + + public void CopyTo (T[] array,int arrayIndex) { + + } + + public IEnumerator GetEnumerator () { + return Enumerable.Empty().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator () { + return GetEnumerator(); + } + } + } \ No newline at end of file