internal bool ReplaceIfNeededWith(ICollection <T> items)
        {
            using (AsyncReaderWriterLock.UpgradeableReaderKey readerKey = Lock.UpgradeableReaderLock()) {
                if (HashSet.SetEquals(items))
                {
                    return(false);
                }

                ReplaceWith(items, readerKey);
                return(true);
            }
        }
        private void ReplaceWith(IEnumerable <T> items, AsyncReaderWriterLock.UpgradeableReaderKey readerKey)
        {
            using (readerKey.Upgrade()) {
                HashSet.Clear();

                foreach (T item in items)
                {
                    HashSet.Add(item);
                }

                HashSet.TrimExcess();
            }
        }