Esempio n. 1
0
        public static HashSet <T> ToHashSetPooled <T>(this IEnumerable <T> source)
        {
            var hashSet = HashSetPool <T> .New();

            foreach (var item in source)
            {
                hashSet.Add(item);
            }

            return(hashSet);
        }
Esempio n. 2
0
        private void ManagedFilter(QueryFilter filter)
        {
            if (filter.pass == 0)
            {
                // UnionWith would box the GameObjects HashSet into an IEnumerable
                foreach (var gameObject in gameObjects)
                {
                    filter.set.Add(gameObject);
                }

                foreach (var component in components)
                {
                    filter.Map(((IComponent)component).gameObject, component);
                }
            }
            else
            {
                // IntersectWith would box the GameObjects HashSet into an IEnumerable

                var toRemove = HashSetPool <GameObject> .New();

                foreach (var gameObject in filter.set)
                {
                    if (!gameObjects.Contains(gameObject))
                    {
                        toRemove.Add(gameObject);
                    }
                }

                foreach (var gameObject in toRemove)
                {
                    filter.set.Remove(gameObject);
                }

                toRemove.Free();

                foreach (var go in filter.set)
                {
                    filter.Map(go, map[go][0]);
                }
            }
        }
Esempio n. 3
0
 public static void Free <T>(this HashSet <T> hashSet)
 {
     HashSetPool <T> .Free(hashSet);
 }