From 31525ff4a76773fa0cc85d4abcee7d5418cbd984 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 21 Jan 2014 14:51:32 +0700 Subject: Make static utility classes abstract instead of sealed Add Arrays.GetHashCode for int[] Formatting --- crypto/src/util/collections/CollectionUtilities.cs | 65 ++++++++++------------ 1 file changed, 29 insertions(+), 36 deletions(-) (limited to 'crypto/src/util/collections') diff --git a/crypto/src/util/collections/CollectionUtilities.cs b/crypto/src/util/collections/CollectionUtilities.cs index fd0bdcc7a..18fcb6774 100644 --- a/crypto/src/util/collections/CollectionUtilities.cs +++ b/crypto/src/util/collections/CollectionUtilities.cs @@ -4,13 +4,9 @@ using System.Text; namespace Org.BouncyCastle.Utilities.Collections { - public sealed class CollectionUtilities - { - private CollectionUtilities() - { - } - - public static void AddRange(IList to, ICollection range) + public abstract class CollectionUtilities + { + public static void AddRange(IList to, IEnumerable range) { foreach (object o in range) { @@ -18,17 +14,15 @@ namespace Org.BouncyCastle.Utilities.Collections } } - public static bool CheckElementsAreOfType( - IEnumerable e, - Type t) - { - foreach (object o in e) - { - if (!t.IsInstanceOfType(o)) - return false; - } - return true; - } + public static bool CheckElementsAreOfType(IEnumerable e, Type t) + { + foreach (object o in e) + { + if (!t.IsInstanceOfType(o)) + return false; + } + return true; + } public static IDictionary ReadOnly(IDictionary d) { @@ -45,27 +39,26 @@ namespace Org.BouncyCastle.Utilities.Collections return new UnmodifiableSetProxy(s); } - public static string ToString( - IEnumerable c) - { - StringBuilder sb = new StringBuilder("["); + public static string ToString(IEnumerable c) + { + StringBuilder sb = new StringBuilder("["); - IEnumerator e = c.GetEnumerator(); + IEnumerator e = c.GetEnumerator(); - if (e.MoveNext()) - { - sb.Append(e.Current.ToString()); + if (e.MoveNext()) + { + sb.Append(e.Current.ToString()); - while (e.MoveNext()) - { - sb.Append(", "); - sb.Append(e.Current.ToString()); - } - } + while (e.MoveNext()) + { + sb.Append(", "); + sb.Append(e.Current.ToString()); + } + } - sb.Append(']'); + sb.Append(']'); - return sb.ToString(); - } - } + return sb.ToString(); + } + } } -- cgit 1.5.1