Lucene.Net.Core.Support.Collections: Removed commented code
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a3ef60a3 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a3ef60a3 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a3ef60a3 Branch: refs/heads/api-work Commit: a3ef60a3e1396333a556e67f75b1b10dc3664ed9 Parents: d21dd79 Author: Shad Storhaug <[email protected]> Authored: Thu Mar 30 09:15:45 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Thu Mar 30 09:15:45 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Core/Support/Collections.cs | 476 ------------------------ 1 file changed, 476 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a3ef60a3/src/Lucene.Net.Core/Support/Collections.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Support/Collections.cs b/src/Lucene.Net.Core/Support/Collections.cs index 380cf75..4abd26b 100644 --- a/src/Lucene.Net.Core/Support/Collections.cs +++ b/src/Lucene.Net.Core/Support/Collections.cs @@ -190,15 +190,6 @@ namespace Lucene.Net return h; } - //public static int GetHashCode<TKey, TValue>(KeyValuePair<TKey, TValue> kvp) - //{ - // TKey key = kvp.Key; - // TValue value = kvp.Value; - // int keyHash = (key == null ? 0 : GetHashCode(key)); - // int valueHash = (value == null ? 0 : GetHashCode(value)); - // return keyHash ^ valueHash; - //} - /// <summary> /// This method generally assists with the recursive GetHashCode() that /// builds a hash code based on all of the values in a collection @@ -280,18 +271,6 @@ namespace Lucene.Net } return (!(eA.MoveNext() || eB.MoveNext())); - - //while (eA.MoveNext()) - //{ - // if (!eB.MoveNext() || (isValueType ? !eA.Current.Equals(eB.Current) : !Equals(eA.Current, eB.Current))) - // { - // return false; - // } - //} - //if (eB.MoveNext()) - //{ - // return false; - //} } } } @@ -383,22 +362,6 @@ namespace Lucene.Net return false; } - //foreach (var eA in dictionaryA) - //{ - // bool contains = false; - // foreach (var eB in dictionaryB) - // { - // if (Equals(eA, eB)) - // { - // contains = true; - // break; - // } - // } - // if (!contains) - // { - // return false; - // } - //} bool valueIsValueType = typeof(TValue).IsValueType; using (var i = dictionaryB.GetEnumerator()) @@ -429,21 +392,6 @@ namespace Lucene.Net return true; } - //public static bool Equals<TKey, TValue>(KeyValuePair<TKey, TValue> kvpA, KeyValuePair<TKey, TValue> kvpB) - //{ - // return Equals(kvpA, kvpB, false); - //} - - //public static bool Equals<TKey, TValue>(KeyValuePair<TKey, TValue> kvpA, KeyValuePair<TKey, TValue> kvpB, bool deep) - //{ - // return Equals(kvpA.Key, kvpB.Key, deep) && Equals(kvpA.Value, kvpB.Value, deep); - // //if (deep) - // //{ - // // return Equals(kvpA.Key, kvpB.Key, deep) && Equals(kvpA.Value, kvpB.Value, deep); - // //} - // //return kvpA.Equals(kvpB); - //} - /// <summary> /// A helper method to recursively determine equality based on /// the values of the collection and all nested collections. @@ -642,430 +590,6 @@ namespace Lucene.Net } } - - - //public static int GetHashCode<T>(IList<T> list) - //{ - // return GetHashCode(list, false); - //} - - ///// <summary> - ///// The same implementation of GetHashCode from Java's AbstractList - ///// (the default implementation for all lists). - ///// <para/> - ///// This algorithm depends on the order of the items in the list. - ///// </summary> - //public static int GetHashCode<T>(IList<T> list, bool deep) - //{ - // int hashCode = 1; - // foreach (T e in list) - // { - // hashCode = 31 * hashCode + - // // LUCENENET: Value types will never be null, so this is ok - // (e == null ? 0 : - // (deep ? GetHashCode(e, deep) : e.GetHashCode())); - // } - - // return hashCode; - //} - - //public static int GetHashCode<T>(ISet<T> set) - //{ - // return GetHashCode(set, false); - //} - - ///// <summary> - ///// The same implementation of GetHashCode from Java's AbstractSet - ///// (the default implementation for all sets) - ///// <para/> - ///// This algorithm does not depend on the order of the items in the set. - ///// </summary> - //public static int GetHashCode<T>(ISet<T> set, bool deep) - //{ - // int h = 0; - // using (var i = set.GetEnumerator()) - // { - // while (i.MoveNext()) - // { - // T obj = i.Current; - // if (obj != null) // LUCENENET: Value types will never be null, so this is ok - // { - // h += deep ? GetHashCode(obj, deep) : obj.GetHashCode(); - // } - // } - // } - // return h; - //} - - //public static int GetHashCode<TKey, TValue>(IDictionary<TKey, TValue> dictionary) - //{ - // return GetHashCode(dictionary, false); - //} - - ///// <summary> - ///// The same implementation of GetHashCode from Java's AbstractMap - ///// (the default implementation for all dictionaries) - ///// <para/> - ///// This algoritm does not depend on the order of the items in the dictionary. - ///// </summary> - //public static int GetHashCode<TKey, TValue>(IDictionary<TKey, TValue> dictionary, bool deep) - //{ - // int h = 0; - // using (var i = dictionary.GetEnumerator()) - // { - // while (i.MoveNext()) - // { - // h += GetHashCode(i.Current, deep); - // } - // } - // return h; - //} - - //public static int GetHashCode<TKey, TValue>(KeyValuePair<TKey, TValue> kvp) - //{ - // return GetHashCode(kvp, false); - //} - - //public static int GetHashCode<TKey, TValue>(KeyValuePair<TKey, TValue> kvp, bool deep) - //{ - // if (deep) - // { - // TKey key = kvp.Key; - // TValue value = kvp.Value; - // int keyHash = (key == null ? 0 : GetHashCode(key, deep)); - // int valueHash = (value == null ? 0 : GetHashCode(value, deep)); - // return keyHash ^ valueHash; - // } - // return kvp.GetHashCode(); - //} - - //public static int GetHashCode(object obj) - //{ - // return GetHashCode(obj, false); - //} - - //public static int GetHashCode(object obj, bool deep) - //{ - // Type t = obj.GetType(); - // if (t.IsGenericType - // && (t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(IList<>))) - // || t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(ISet<>))) - // || t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(IDictionary<,>))))) - // { - // dynamic genericType = Convert.ChangeType(obj, t); - // return GetHashCode(genericType, deep); - // } - - // return obj.GetHashCode(); - //} - - //public static bool Equals<T>(IList<T> listA, IList<T> listB) - //{ - // return Equals(listA, listB, false); - //} - - ///// <summary> - ///// The same implementation of Equals from Java's AbstractList - ///// (the default implementation for all lists) - ///// <para/> - ///// This algorithm depends on the order of the items in the list. - ///// </summary> - //public static bool Equals<T>(IList<T> listA, IList<T> listB, bool deep) - //{ - // if (object.ReferenceEquals(listA, listB)) - // { - // return true; - // } - - // if (listA == null) - // { - // if (listB == null) - // { - // return true; - // } - // return false; - // } - - // using (IEnumerator<T> eA = listA.GetEnumerator()) - // { - // using (IEnumerator<T> eB = listB.GetEnumerator()) - // { - // while (eA.MoveNext()) - // { - // if (!eB.MoveNext() || (deep ? Equals(eA, eB, deep) : !eA.Current.Equals(eB.Current))) - // { - // return false; - // } - // } - // if (eB.MoveNext()) - // { - // return false; - // } - // } - // } - // return true; - //} - - //public static bool Equals<T>(ISet<T> setA, ISet<T> setB) - //{ - // return Equals(setA, setB, false); - //} - - ///// <summary> - ///// The same implementation of Equals from Java's AbstractSet - ///// (the default implementation for all sets) - ///// <para/> - ///// This algoritm does not depend on the order of the items in the set. - ///// </summary> - //public static bool Equals<T>(ISet<T> setA, ISet<T> setB, bool deep) - //{ - // if (object.ReferenceEquals(setA, setB)) - // { - // return true; - // } - - // if (setA == null) - // { - // if (setB == null) - // { - // return true; - // } - // return false; - // } - - // if (setA.Count != setB.Count) - // { - // return false; - // } - - // // same operation as containsAll() - // foreach (T eB in setB) - // { - // bool contains = false; - // foreach (T eA in setA) - // { - // if (deep ? Equals(eA, eB, deep) : eA.Equals(eB)) - // { - // contains = true; - // break; - // } - // } - // if (!contains) - // { - // return false; - // } - // } - - // return true; - //} - - //public static bool Equals<TKey, TValue>(IDictionary<TKey, TValue> dictionaryA, IDictionary<TKey, TValue> dictionaryB) - //{ - // return Equals(dictionaryA, dictionaryB, false); - //} - - ///// <summary> - ///// This is the same implemenation of Equals from Java's AbstractMap - ///// (the default implementation of all dictionaries) - ///// <para/> - ///// This algoritm does not depend on the order of the items in the dictionary. - ///// </summary> - //public static bool Equals<TKey, TValue>(IDictionary<TKey, TValue> dictionaryA, IDictionary<TKey, TValue> dictionaryB, bool deep) - //{ - // if (object.ReferenceEquals(dictionaryA, dictionaryB)) - // { - // return true; - // } - - // if (dictionaryA == null) - // { - // if (dictionaryB == null) - // { - // return true; - // } - // return false; - // } - - // if (dictionaryA.Count != dictionaryB.Count) - // { - // return false; - // } - - // foreach (var eA in dictionaryA) - // { - // bool contains = false; - // foreach (var eB in dictionaryB) - // { - // if (deep ? Equals(eA, eB, deep) : eA.GetHashCode().Equals(eB.GetHashCode())) - // { - // contains = true; - // break; - // } - // } - // if (!contains) - // { - // return false; - // } - // } - - - // //using (var i = dictionaryA.GetEnumerator()) - // //{ - // // while(i.MoveNext()) - // // { - // // KeyValuePair<TKey, TValue> e = i.Current; - - - // // //TKey key = e.Key; - // // //TValue value = e.Value; - // // //if (value == null) - // // //{ - // // // if (!(dictionaryB.ContainsKey(key))) - // // // { - // // // return false; - // // // } - // // //} - // // //else - // // //{ - // // // TValue valueB; - // // // if (!dictionaryB.TryGetValue(key, out valueB) || !(deep ? Equals(value, valueB, deep) : value.Equals(valueB))) - // // // { - // // // return false; - // // // } - // // //} - // // } - // //} - - // return true; - //} - - //public static bool Equals<TKey, TValue>(KeyValuePair<TKey, TValue> kvpA, KeyValuePair<TKey, TValue> kvpB) - //{ - // return Equals(kvpA, kvpB, false); - //} - - //public static bool Equals<TKey, TValue>(KeyValuePair<TKey, TValue> kvpA, KeyValuePair<TKey, TValue> kvpB, bool deep) - //{ - // return Equals(kvpA.Key, kvpB.Key, deep) && Equals(kvpA.Value, kvpB.Value, deep); - // //if (deep) - // //{ - // // return Equals(kvpA.Key, kvpB.Key, deep) && Equals(kvpA.Value, kvpB.Value, deep); - // //} - // //return kvpA.Equals(kvpB); - //} - - //new public static bool Equals(object objA, object objB) - //{ - // return Equals(objA, objB, false); - //} - - //public static bool Equals(object objA, object objB, bool deep) - //{ - // Type t = objA.GetType(); - // if (t.IsGenericType - // && (t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(IList<>))) - // || t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(ISet<>))) - // || t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(IDictionary<,>))))) - // { - // dynamic genericType = Convert.ChangeType(objA, t); - // return Equals(genericType, objB, deep); - // } - - // return objA.Equals(objB); - //} - - - //public static string ToString<T>(ICollection<T> collection) - //{ - // return ToString(collection, true); - //} - - ///// <summary> - ///// This is the same implementation of ToString from Java's AbstractCollection - ///// (the default implementation for all sets and lists) - ///// </summary> - //public static string ToString<T>(ICollection<T> collection, bool deep) - //{ - // if (collection.Count == 0) - // { - // return "[]"; - // } - - // using (var it = collection.GetEnumerator()) - // { - // StringBuilder sb = new StringBuilder(); - // sb.Append('['); - // it.MoveNext(); - // while (true) - // { - // T e = it.Current; - // sb.Append(object.ReferenceEquals(e, collection) ? "(this Collection)" : deep ? ToString(e, deep) : e.ToString()); - // if (!it.MoveNext()) - // { - // return sb.Append(']').ToString(); - // } - // sb.Append(',').Append(' '); - // } - // } - //} - - //public static string ToString<TKey, TValue>(IDictionary<TKey, TValue> dictionary) - //{ - // return ToString(dictionary, true); - //} - - ///// <summary> - ///// This is the same implementation of ToString from Java's AbstractMap - ///// (the default implementation for all dictionaries) - ///// </summary> - //public static string ToString<TKey, TValue>(IDictionary<TKey, TValue> dictionary, bool deep) - //{ - // if (dictionary.Count == 0) - // { - // return "{}"; - // } - - // using (var i = dictionary.GetEnumerator()) - // { - // StringBuilder sb = new StringBuilder(); - // sb.Append('{'); - // i.MoveNext(); - // while (true) - // { - // KeyValuePair<TKey, TValue> e = i.Current; - // TKey key = e.Key; - // TValue value = e.Value; - // sb.Append(object.ReferenceEquals(key, dictionary) ? "(this Dictionary)" : deep ? ToString(key, deep) : key.ToString()); - // sb.Append('='); - // sb.Append(object.ReferenceEquals(value, dictionary) ? "(this Dictionary)" : deep ? ToString(value, deep) : value.ToString()); - // if (!i.MoveNext()) - // { - // return sb.Append('}').ToString(); - // } - // sb.Append(',').Append(' '); - // } - // } - //} - - //public static string ToString(object obj) - //{ - // return ToString(obj, true); - //} - - //public static string ToString(object obj, bool deep) - //{ - // Type t = obj.GetType(); - // if (t.IsGenericType - // && (t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(ICollection<>))) - // || t.GetGenericTypeDefinition().GetInterfaces().Any(x => x.IsAssignableFrom(typeof(IDictionary<,>))))) - // { - // dynamic genericType = Convert.ChangeType(obj, t); - // return ToString(genericType, deep); - // } - - // return obj.ToString(); - //} - #region Nested Types #region SetFromMap
