Exemplo n.º 1
0
        public RelValueST <T> Extend <T>(Func <Ttup, object> func)
            where T : TupBase, new()
        {
            var newbody = RelOpsST.Extend <Ttup, T>(this, func);

            return(RelValueST <T> .Create <RelValueST <T> >(newbody));
        }
Exemplo n.º 2
0
        // generate a new relation with one attribute renamed
        public RelValueST <T> Rename <T>()
            where T : TupBase, new()
        {
            var newbody = RelOpsST.Rename <Ttup, T>(this);

            return(RelValueST <T> .Create <RelValueST <T> >(newbody));
        }
Exemplo n.º 3
0
        public RelValueST <T> Transform <T>(Func <Ttup, T> func)
            where T : TupBase, new()
        {
            var newbody = RelOpsST.Transform <Ttup, T>(this, func);

            return(RelValueST <T> .Create <RelValueST <T> >(newbody));
        }
Exemplo n.º 4
0
        public RelValueST <Ttup> While <Trel>(Func <Trel, RelValueST <Ttup> > func)
            where Trel : RelValueST <Ttup>, new()
        {
            var newbody = RelOpsST.While <Ttup, Trel>(this, func);

            return(RelValueST <Ttup> .Create <RelValueST <Ttup> >(newbody));
        }
Exemplo n.º 5
0
        public RelValueST <T> Aggregate <T, T1>(Func <Ttup, T1, T1> func)
            where T : TupBase, new()
            where T1 : new()
        {
            var newbody = RelOpsST.Aggregate <Ttup, T, T1>(this, func);

            return(RelValueST <T> .Create <RelValueST <T> >(newbody));
        }
Exemplo n.º 6
0
        public RelValueST <T> AntiJoin <T1, T>(RelValueST <T1> other)
            where T : TupBase, new()
            where T1 : TupBase, new()
        {
            var newbody = RelOpsST.AntiJoin <T, Ttup, T1>(this, other);

            return(RelValueST <T> .Create <RelValueST <T> >(newbody));
        }
Exemplo n.º 7
0
        // fixed point recursion
        internal static HashSet <T> While <T, TR>(IEnumerable <T> body, Func <TR, RelValueST <T> > func)
            where T : TupBase, new()
            where TR : RelValueST <T>, new()
        {
            var stack   = new Stack <T>(body);
            var newbody = new HashSet <T>();

            while (stack.Count > 0)
            {
                var top = stack.Pop();
                if (!newbody.Contains(top))
                {
                    newbody.Add(top);
                    var rel = RelValueST <T> .Create <TR>(Enumerable.Repeat(top, 1));

                    foreach (var t in func(rel))
                    {
                        stack.Push(t);
                    }
                }
            }
            return(newbody);
        }
Exemplo n.º 8
0
 public RelVarST(RelValueST <T> tuples)
 {
     Value   = Rel.Create(tuples);
     Heading = RelBaseST <T> .Heading;
 }
Exemplo n.º 9
0
 // insert tuples, discard duplicates
 public void Insert(RelValueST <T> value)
 {
     Value = Rel.Create(RelOpsST.Union(Value, value));
 }
Exemplo n.º 10
0
 public static new Rel Create(IEnumerable <T> tuples)
 {
     return(RelValueST <T> .Create <Rel>(tuples));
 }
Exemplo n.º 11
0
        // generate a new relation that is a set union
        public RelValueST <Ttup> Union(RelValueST <Ttup> other)
        {
            var newbody = RelOpsST.Union <Ttup>(this, other);

            return(Create <RelValueST <Ttup> >(newbody));
        }
Exemplo n.º 12
0
 // relational assignment
 public void Assign(RelValueST <T> value)
 {
     Value = Rel.Create(value);
 }
Exemplo n.º 13
0
 // this relation has no tuples in common with other
 public bool IsDisjoint(RelValueST <Ttup> other)
 {
     return(!this.Any(b => other.Contains(b)));
 }
Exemplo n.º 14
0
 // this relation is a superset of other
 public bool IsSuperset(RelValueST <Ttup> other)
 {
     return(other.All(b => this.Contains(b)));
 }
Exemplo n.º 15
0
 // this relation is a subset of other
 public bool IsSubset(RelValueST <Ttup> other)
 {
     return(this.All(b => other.Contains(b)));
 }
Exemplo n.º 16
0
        // generate a new relation that is a set minus
        public RelValueST <Ttup> Minus(RelValueST <Ttup> other)
        {
            var newbody = RelOpsST.Minus <Ttup>(this, other);

            return(Create <RelValueST <Ttup> >(newbody));
        }
Exemplo n.º 17
0
        // generate a new relation that is a set intersection
        public RelValueST <Ttup> Intersect(RelValueST <Ttup> other)
        {
            var newbody = RelOpsST.Intersect <Ttup>(this, other);

            return(Create <RelValueST <Ttup> >(newbody));
        }