diff options
Diffstat (limited to 'crypto/src/util/collections/CollectionUtilities.cs')
-rw-r--r-- | crypto/src/util/collections/CollectionUtilities.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crypto/src/util/collections/CollectionUtilities.cs b/crypto/src/util/collections/CollectionUtilities.cs index 26b3f2a1d..a1fb0e949 100644 --- a/crypto/src/util/collections/CollectionUtilities.cs +++ b/crypto/src/util/collections/CollectionUtilities.cs @@ -31,6 +31,19 @@ namespace Org.BouncyCastle.Utilities.Collections return new StoreImpl<T>(contents); } + public static T GetFirstOrNull<T>(IEnumerable<T> e) + where T : class + { + if (e != null) + { + foreach (var t in e) + { + return t; + } + } + return null; + } + public static T GetValueOrKey<T>(IDictionary<T, T> d, T k) { return d.TryGetValue(k, out var v) ? v : k; |