Ejemplo n.º 1
0
        // Returns a set of @this which depends on any state in @states.
        // In addition, @rest will contain the inverse set (i.e. everyting in
        // @this which did _not_ depend on any state in @states).
        public DependencyFilter DependsOn(IEnumerable <State> states)
        {
            DependencyFilter ret = (d_filter ? this : new DependencyFilter(d_graph, this));

            ret.d_not = null;

            // Check for each state if it depends on a state in states. If so, it should
            // be in the result set, if not it should be in the rest set
            ret.RemoveWhere((s) => {
                bool doesdepend = false;

                foreach (State other in states)
                {
                    if (d_graph.DependsOn(s, other.Object))
                    {
                        doesdepend = true;
                        break;
                    }
                }

                if (!doesdepend)
                {
                    if (ret.d_not == null)
                    {
                        ret.d_not = new DependencyFilter(d_graph);
                    }

                    ret.d_not.Add(s);
                }

                return(!doesdepend);
            });

            return(ret);
        }
Ejemplo n.º 2
0
        public DependencyFilter DependencyOf(IEnumerable <State> states)
        {
            DependencyFilter ret = (d_filter ? this : new DependencyFilter(d_graph, this));

            ret.d_not = null;

            ret.RemoveWhere((s) => {
                bool doesdepend = false;

                foreach (State other in states)
                {
                    if (d_graph.DependsOn(other, s.Object))
                    {
                        doesdepend = true;
                        break;
                    }
                }

                if (!doesdepend)
                {
                    if (ret.d_not == null)
                    {
                        ret.d_not = new DependencyFilter(d_graph);
                    }

                    ret.d_not.Add(s);
                }

                return(!doesdepend);
            });

            return(ret);
        }
Ejemplo n.º 3
0
        public DependencyFilter Copy()
        {
            var ret = new DependencyFilter(d_graph, this);

            if (d_not != null)
            {
                ret.d_not = d_not.Copy();
            }

            return(ret);
        }
Ejemplo n.º 4
0
        public DependencyFilter Not()
        {
            if (d_filter)
            {
                var n = d_not;

                if (Count == 0)
                {
                    d_not = null;
                }
                else
                {
                    d_not = new DependencyFilter(d_graph, this);
                }

                Clear();

                if (n != null)
                {
                    UnionWith(n);
                }

                return(this);
            }
            else
            {
                if (d_not != null)
                {
                    return(d_not);
                }
                else
                {
                    return(new DependencyFilter(d_graph));
                }
            }
        }