.Net 中的 HashSet.Contains 实现是:
/// <summary>
/// Checks if this hashset contains the item
/// </summary>
/// <param name="item">item to check for containment</param>
/// <returns>true if item contained; false if not</returns>
public bool Contains(T item) {
if (m_buckets != null) {
int hashCode = InternalGetHashCode(item);
// see note at "HashSet" level describing why "- 1" appears in for loop
for (int i = m_buckets[hashCode % m_buckets.Length] - 1; i >= 0; i = m_slots[i].next) {
if (m_slots[i].hashCode == hashCode && …Run Code Online (Sandbox Code Playgroud) 在一组价值观中
[0, 2, 25, 30]
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用linq
[0, 0, 0, 2, 2, 2, 25, 25, 25, 30, 30, 30] //Replicate 2 times (values repeated 3 times)
Run Code Online (Sandbox Code Playgroud)
有没有办法用linq做到这一点?