summary refs log tree commit diff
path: root/crypto/src/util/collections/StoreImpl.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-26 19:34:14 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-26 19:34:14 +0700
commitc8bba37510f01f116fea99204e934d35863a9d2b (patch)
tree799f39da3e8b2dc53a94b4f5e735626a83c8f7ef /crypto/src/util/collections/StoreImpl.cs
parentReorganize test vector tests (diff)
downloadBouncyCastle.NET-ed25519-c8bba37510f01f116fea99204e934d35863a9d2b.tar.xz
Add store/selector API
Diffstat (limited to '')
-rw-r--r--crypto/src/util/collections/StoreImpl.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/crypto/src/util/collections/StoreImpl.cs b/crypto/src/util/collections/StoreImpl.cs
new file mode 100644
index 000000000..3a7135007
--- /dev/null
+++ b/crypto/src/util/collections/StoreImpl.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace Org.BouncyCastle.Utilities.Collections
+{
+    internal sealed class StoreImpl<T>
+        : IStore<T>
+    {
+        private readonly List<T> m_contents;
+
+        internal StoreImpl(IEnumerable<T> e)
+        {
+            m_contents = new List<T>(e);
+        }
+
+        IEnumerable<T> IStore<T>.EnumerateMatches(ISelector<T> selector)
+        {
+            foreach (T candidate in m_contents)
+            {
+                if (selector == null || selector.Match(candidate))
+                    yield return candidate;
+            }
+        }
+    }
+}