Exemplo n.º 1
0
        public bool Add(T item)
        {
            var hashCode = GetHashCode(item);

            for (var attempts = 0; ; attempts++)
            {
                ExtendProbingIfNeeded(attempts);
                if (_bucket.Insert(hashCode + attempts, item, out var found))
                {
                    return(true);
                }

                if (Comparer.Equals(found, item))
                {
                    return(false);
                }
            }
        }
Exemplo n.º 2
0
        public bool Add(T item)
        {
            var hashCode = _comparer.GetHashCode(item);
            var attempts = 0;

            while (true)
            {
                ExtendProbingIfNeeded(attempts);
                T found;
                if (_bucket.Insert(hashCode + attempts, item, out found))
                {
                    return(true);
                }
                if (_comparer.Equals(found, item))
                {
                    return(false);
                }
                attempts++;
            }
        }