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
        public static IEnumerable <T> OrderByDependencies <T>(this IEnumerable <T> source, Func <T, IEnumerable <T> > getDependencies, bool throwOnCycle = true)
        {
            var sorted  = new List <T>();
            var visited = HashSetPool <T> .New();

            foreach (var item in source)
            {
                OrderByDependenciesVisit(item, visited, sorted, getDependencies, throwOnCycle);
            }

            HashSetPool <T> .Free(visited);

            return(sorted);
        }
Esempio n. 3
0
        protected void FreeInvalidChildren()
        {
            var toFree = HashSetPool <Inspector> .New();

            foreach (var child in children)
            {
                if (!child.Key.isLinked)
                {
                    toFree.Add(child.Value);
                }
            }

            foreach (var invalid in toFree)
            {
                invalid.Dispose();
                children.Remove(invalid.accessor);
            }

            toFree.Free();
        }