/// <summary>
 /// Insert single item on scope start, and remove on scope exit
 /// </summary>
 /// <param name="singleItem">Item to insert in scope</param>
 /// <param name="existing">Existing hashset to update</param>
 /// <param name="forceHashSet">Force allocation of real hashset-container</param>
 public SingleItemScopedInsert(T singleItem, ref SingleItemOptimizedHashSet <T> existing, bool forceHashSet)
 {
     _singleItem = singleItem;
     if (existing._hashset != null)
     {
         existing._hashset.Add(singleItem);
         _hashset = existing._hashset;
     }
     else if (forceHashSet)
     {
         existing = new SingleItemOptimizedHashSet <T>(singleItem, existing);
         existing.Add(singleItem);
         _hashset = existing._hashset;
     }
     else
     {
         existing = new SingleItemOptimizedHashSet <T>(singleItem, existing);
         _hashset = null;
     }
 }
 public SingleItemOptimizedHashSet(T singleItem, SingleItemOptimizedHashSet <T> existing)
 {
     if (existing._hashset != null)
     {
         _hashset = new HashSet <T>(existing._hashset);
         _hashset.Add(singleItem);
         _singleItem = default(T);
     }
     else if (existing.Count == 1)
     {
         _hashset = new HashSet <T>();
         _hashset.Add(existing._singleItem);
         _hashset.Add(singleItem);
         _singleItem = default(T);
     }
     else
     {
         _hashset    = null;
         _singleItem = singleItem;
     }
 }
 public SingleItemOptimizedHashSet(T singleItem, SingleItemOptimizedHashSet <T> existing, IEqualityComparer <T> comparer = null)
 {
     _comparer = existing._comparer ?? comparer ?? EqualityComparer <T> .Default;
     if (existing._hashset != null)
     {
         _hashset = new HashSet <T>(existing._hashset, _comparer);
         _hashset.Add(singleItem);
         _singleItem = default(T);
     }
     else if (existing.Count == 1)
     {
         _hashset = new HashSet <T>(_comparer);
         _hashset.Add(existing._singleItem);
         _hashset.Add(singleItem);
         _singleItem = default(T);
     }
     else
     {
         _hashset    = null;
         _singleItem = singleItem;
     }
 }