-Rewrote LINQ to JSON internals to use lists and dictionaries rather than a linked list

-Moved JPropertyDescriptor to Newtonsoft.Json.Linq namespace
This commit is contained in:
JamesNK
2011-05-28 00:46:38 +00:00
parent cc44f53c1a
commit b3cc3e88ac
19 changed files with 337 additions and 337 deletions
@@ -631,5 +631,39 @@ namespace Newtonsoft.Json.Utilities
return -1;
}
/// <summary>
/// Returns the index of the first occurrence in a sequence by using the default equality comparer.
/// </summary>
/// <typeparam name="TSource">The type of the elements of source.</typeparam>
/// <param name="list">A sequence in which to locate a value.</param>
/// <param name="value">The object to locate in the sequence</param>
/// <returns>The zero-based index of the first occurrence of value within the entire sequence, if found; otherwise, –1.</returns>
public static int IndexOf<TSource>(this IEnumerable<TSource> list, TSource value) where TSource : IEquatable<TSource>
{
return list.IndexOf<TSource>(value, EqualityComparer<TSource>.Default);
}
/// <summary>
/// Returns the index of the first occurrence in a sequence by using a specified IEqualityComparer.
/// </summary>
/// <typeparam name="TSource">The type of the elements of source.</typeparam>
/// <param name="list">A sequence in which to locate a value.</param>
/// <param name="value">The object to locate in the sequence</param>
/// <param name="comparer">An equality comparer to compare values.</param>
/// <returns>The zero-based index of the first occurrence of value within the entire sequence, if found; otherwise, –1.</returns>
public static int IndexOf<TSource>(this IEnumerable<TSource> list, TSource value, IEqualityComparer<TSource> comparer)
{
int index = 0;
foreach (TSource item in list)
{
if (comparer.Equals(item, value))
{
return index;
}
index++;
}
return -1;
}
}
}