summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1Set.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-09-14 17:25:07 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-09-14 17:25:07 +0700
commit70efdd3343573c6c2686486cf308490dd4a20d24 (patch)
tree396eb8424871e4e65656866191d851e53f151169 /crypto/src/asn1/Asn1Set.cs
parentDateTimeObject => nullable DateTime (diff)
downloadBouncyCastle.NET-ed25519-70efdd3343573c6c2686486cf308490dd4a20d24.tar.xz
Add MapElements methods
Diffstat (limited to 'crypto/src/asn1/Asn1Set.cs')
-rw-r--r--crypto/src/asn1/Asn1Set.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/src/asn1/Asn1Set.cs b/crypto/src/asn1/Asn1Set.cs
index 1045b7f74..b2a654d68 100644
--- a/crypto/src/asn1/Asn1Set.cs
+++ b/crypto/src/asn1/Asn1Set.cs
@@ -162,6 +162,18 @@ namespace Org.BouncyCastle.Asn1
             get { return elements.Length; }
         }
 
+        public virtual T[] MapElements<T>(Func<Asn1Encodable, T> func)
+        {
+            // NOTE: Call Count here to 'force' a LazyDerSet
+            int count = Count;
+            T[] result = new T[count];
+            for (int i = 0; i < count; ++i)
+            {
+                result[i] = func(elements[i]);
+            }
+            return result;
+        }
+
         public virtual Asn1Encodable[] ToArray()
         {
             return Asn1EncodableVector.CloneElements(elements);