Exemplo n.º 1
0
 public static void Or <T>(UnsafeHashSet *set, UnsafeHashSet *other) where T : unmanaged, IEquatable <T>
 {
     for (int i = other->_collection.UsedCount - 1; i >= 0; --i)
     {
         var entry = UnsafeHashCollection.GetEntry(&other->_collection, i);
         if (entry->State == UnsafeHashCollection.EntryState.Used)
         {
             // always add to this collection
             Add <T>(set, *(T *)((byte *)entry + other->_collection.KeyOffset));
         }
     }
 }
            public bool Next()
            {
                while (++_index < Collection->UsedCount)
                {
                    var entry = UnsafeHashCollection.GetEntry(Collection, _index);
                    if (entry->State == EntryState.Used)
                    {
                        Current = entry;
                        return(true);
                    }
                }

                Current = null;
                return(false);
            }
Exemplo n.º 3
0
        public static void And <T>(UnsafeHashSet *set, UnsafeHashSet *other) where T : unmanaged, IEquatable <T>
        {
            for (int i = set->_collection.UsedCount - 1; i >= 0; --i)
            {
                var entry = UnsafeHashCollection.GetEntry(&set->_collection, i);
                if (entry->State == UnsafeHashCollection.EntryState.Used)
                {
                    var key     = *(T *)((byte *)entry + set->_collection.KeyOffset);
                    var keyHash = key.GetHashCode();

                    // if we don't find this in other collection, remove it (And)
                    if (UnsafeHashCollection.Find <T>(&other->_collection, key, keyHash) == null)
                    {
                        UnsafeHashCollection.Remove <T>(&set->_collection, key, keyHash);
                    }
                }
            }
        }