File: System\Collections\Frozen\SmallFrozenSet.AlternateLookup.cs
Web Access
Project: src\src\libraries\System.Collections.Immutable\src\System.Collections.Immutable.csproj (System.Collections.Immutable)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Collections.Generic;
 
namespace System.Collections.Frozen
{
    internal sealed partial class SmallFrozenSet<T>
    {
        /// <inheritdoc />
        private protected override int FindItemIndex<TAlternate>(TAlternate item)
        {
            IAlternateEqualityComparer<TAlternate, T> comparer = GetAlternateEqualityComparer<TAlternate>();
 
            T[] items = _items;
            for (int i = 0; i < items.Length; i++)
            {
                if (comparer.Equals(item, items[i]))
                {
                    return i;
                }
            }
 
            return -1;
        }
    }
}