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)); }
// 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)); }
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)); }
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)); }
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)); }
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)); }
// 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); }
public RelVarST(RelValueST <T> tuples) { Value = Rel.Create(tuples); Heading = RelBaseST <T> .Heading; }
// insert tuples, discard duplicates public void Insert(RelValueST <T> value) { Value = Rel.Create(RelOpsST.Union(Value, value)); }
public static new Rel Create(IEnumerable <T> tuples) { return(RelValueST <T> .Create <Rel>(tuples)); }
// 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)); }
// relational assignment public void Assign(RelValueST <T> value) { Value = Rel.Create(value); }
// this relation has no tuples in common with other public bool IsDisjoint(RelValueST <Ttup> other) { return(!this.Any(b => other.Contains(b))); }
// this relation is a superset of other public bool IsSuperset(RelValueST <Ttup> other) { return(other.All(b => this.Contains(b))); }
// this relation is a subset of other public bool IsSubset(RelValueST <Ttup> other) { return(this.All(b => other.Contains(b))); }
// 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)); }
// 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)); }