protected override bool InternalDefault(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, string columnName, bool isDescending) { if (isDescending) { BitArray localValueFlags = newRow.GetValueFlags(); bool changed = false; if (PropagateDefaultLeft) { changed = LeftNode.Default(program, oldRow, newRow, valueFlags, columnName); } if (PropagateDefaultRight) { changed = RightNode.Default(program, oldRow, newRow, valueFlags, columnName) || changed; } if (changed) { for (int index = 0; index < newRow.DataType.Columns.Count; index++) { if (!localValueFlags[index] && newRow.HasValue(index)) { Change(program, oldRow, newRow, valueFlags, newRow.DataType.Columns[index].Name); } } } return(changed); } return(false); }
/// <summary> /// 生成包含末节的树 /// </summary> /// <param name="parentId"></param> /// <param name="allList"></param> /// <returns></returns> private List <RightNode> createTree(long parentId, List <Base_Company> allList, string chk = "") { List <RightNode> list = new List <RightNode>(); var childList = allList.Where(i => i.PId == parentId).ToList(); //有子公司 if (childList != null && childList.Any()) { foreach (var item in childList) { RightNode node = new RightNode(); node.checkboxValue = item.Id.ToString(); node.@checked = false; if (item.Id.ToString() == chk) { node.@checked = true; } node.data = new { code = item.Code, id = item.Id.ToString() }; node.name = item.Name; node.spread = true; var iteratorList = createTree(item.Id, allList, chk); node.children = iteratorList; list.Add(node); } } return(list); }
public void Add(IBinaryTreeNode <TItem> node) { if (Item.CompareTo(node.Item) > 0) { if (LeftNode == null) { LeftNode = node; } else { LeftNode.Add(node); } } else if (Item.CompareTo(node.Item) < 0) { if (RightNode == null) { RightNode = node; } else { RightNode.Add(node); } } }
public void InOrderTraversal() { if (LeftNode != null) { LeftNode.InOrderTraversal(); } //Then we print the root node Console.WriteLine("\nTitle: {0}", this.Title); Console.WriteLine("Staring: {0}", string.Join(", ", this.Starring)); Console.WriteLine("Director: {0}", this.Director); Console.WriteLine("Genre: {0}", this.Genre); Console.WriteLine("Classification: {0}", this.Classification); Console.WriteLine("Duration: {0} minutes", this.Duration); Console.WriteLine("Release Date: {0}", this.ReleaseDate); Console.WriteLine("Copies That Exist: {0}", this.NumberOfCopiesThatExist); Console.WriteLine("Copies Available: {0}", this.NumberOfCopiesAvailable); Console.WriteLine("Times Borrowed: {0}\n", this.NumTimesBorrowed); //Then we go to the right node which will print itself as both its children are null if (RightNode != null) { RightNode.InOrderTraversal(); } }
public BipartiteMatching(SCG.IEnumerable <Rec <TLeftLabel, TRightLabel> > graph) { HashDictionary <TRightLabel, RightNode> rdict = new HashDictionary <TRightLabel, RightNode>(); HashDictionary <TLeftLabel, HashSet <RightNode> > edges = new HashDictionary <TLeftLabel, HashSet <RightNode> >(); HashSet <RightNode> newrnodes = new HashSet <RightNode>(); foreach (Rec <TLeftLabel, TRightLabel> edge in graph) { var x2 = edge.X2; if (!rdict.Find(ref x2, out RightNode rnode)) { rdict.Add(edge.X2, rnode = new RightNode(edge.X2)); } HashSet <RightNode> ledges = newrnodes; if (!edges.FindOrAdd(edge.X1, ref ledges)) { newrnodes = new HashSet <RightNode>(); } ledges.Add(rnode); } rightNodes = rdict.Values.ToArray(); leftNodes = new LeftNode[edges.Count]; int li = 0; foreach (KeyValuePair <TLeftLabel, HashSet <RightNode> > les in edges) { leftNodes[li++] = new LeftNode(les.Key, les.Value.ToArray()); } Compute(); }
public static Block ToBlock(this RightNode node, Channel _chan = null) { return(new Paragraph(node.ToInline()) { TextAlignment = TextAlignment.Right }); }
public sealed override object Evaluate(NodeEvaluationContext evaluationContext) { var leftNodeValue = LeftNode.Evaluate(evaluationContext); if (leftNodeValue == DependencyProperty.UnsetValue) { return(DependencyProperty.UnsetValue); } var leftNodeValueType = GetNodeValueType(leftNodeValue); if (leftNodeValueType == NodeValueType.Boolean) { // give base a chance to yield a result without evaluating the right node var result = this.DetermineResultPreRightEvaluation((bool)leftNodeValue); if (result.HasValue) { return(result.Value); } } var rightNodeValue = RightNode.Evaluate(evaluationContext); if (rightNodeValue == DependencyProperty.UnsetValue) { return(DependencyProperty.UnsetValue); } var rightNodeValueType = GetNodeValueType(rightNodeValue); exceptionHelper.ResolveAndThrowIf(leftNodeValueType != NodeValueType.Boolean || rightNodeValueType != NodeValueType.Boolean, "OperandsNotBoolean", this.OperatorSymbols, leftNodeValueType, rightNodeValueType); return(this.DetermineResultPostRightEvaluation((bool)leftNodeValue, (bool)rightNodeValue)); }
public void Add(T value) { if (value.Equals(Value)) { if (RightNode != null) { RightNode = new Node <T>(value); } else { RightNode.Add(value); } } else { if (LeftNode != null) { LeftNode.Add(value); } else { LeftNode = new Node <T>(value); } } }
/// <summary> /// 获取权限树 /// </summary> /// <param name="belong"></param> /// <param name="pId"></param> /// <returns></returns> public RightNode GetRightTree(RoleType roleType, long pId, long userId) { Result <List <Base_Right> > result = new Result <List <Base_Right> >(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.LoadRightList(roleType, userId); } RightNode rootTree = new RightNode(); var list = result.Data.Where(i => i.IsMenu).ToList(); list.Insert(0, Helper.AdminSite); var first = list.FirstOrDefault(i => i.Id == pId); rootTree.checkboxValue = first.Id.ToString(); rootTree.@checked = false; rootTree.data = new { code = first.Code, id = first.SId, url = string.IsNullOrEmpty(first.URL) ? "javascript:void(0);" : first.URL, icon = string.IsNullOrEmpty(first.Icon) ? "" : first.Icon, target = string.IsNullOrEmpty(first.Target) ? "" : first.Target, display = string.IsNullOrEmpty(first.DisplayName) ? first.Name : first.DisplayName }; rootTree.name = first.Name; rootTree.spread = true; var tree = createTree(first.Id, list); rootTree.children = tree; return(rootTree);; }
public void Add(int data, int rank) { var node = new TreeNode(data); node.Rank = rank; if (node.Value.CompareTo(Value) == -1) { if (LeftNode == null) { node.Rank += 1; LeftNode = node; } else { LeftNode.Add(data, rank + 1); } } else { if (RightNode == null) { node.Rank += 1; RightNode = node; } else { RightNode.Add(data, rank + 1); } } }
public void Insert(MarkGeometryPoint point) { if (Value == null) { Value = point; } else if (IsLesser(Origin, point, Value)) { if (LeftNode == null) { LeftNode = new IntersectionsBinaryTree(Origin, point); } else { LeftNode.Insert(point); } } else { if (RightNode == null) { RightNode = new IntersectionsBinaryTree(Origin, point); } else { RightNode.Insert(point); } } }
public void Insert(int value) { //if the value passed is greater than or equal to the data then insert right node if (value >= Data) { //if rightNode is null, instantiate a new rightNode if (RightNode == null) { RightNode = new TreeNode(value); } //if not null, recursively call insert on the rightNode else { RightNode.Insert(value); } } else { //if the value passed is less than the data, insert left node //if leftNode is null, instantiate one if (LeftNode == null) { LeftNode = new TreeNode(value); } //if not null, recursively call Insert on the leftNode else { LeftNode.Insert(value); } } }
/// <summary> /// 生成包含末节的树 /// </summary> /// <param name="parentId"></param> /// <param name="allList"></param> /// <returns></returns> private List <RightNode> createTree(long parentId, List <Epm_CheckItem> allList) { List <RightNode> list = new List <RightNode>(); var childList = allList.Where(i => i.ParentId == parentId).ToList(); //有子权限 if (childList != null && childList.Any()) { foreach (var item in childList) { RightNode node = new RightNode(); node.checkboxValue = item.Id.ToString(); node.@checked = false; node.data = new { id = item.Id.ToString() }; node.name = item.Name; node.spread = true; node.Level = item.Level; var iteratorList = createTree(item.Id, allList); node.children = iteratorList; list.Add(node); } } return(list); }
protected void InternalInsertRight(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, bool uncheckedValue) { switch (PropagateInsertRight) { case PropagateAction.True: RightNode.Insert(program, oldRow, newRow, valueFlags, uncheckedValue); break; case PropagateAction.Ensure: case PropagateAction.Ignore: using (Row rightRow = new Row(program.ValueManager, RightNode.DataType.RowType)) { newRow.CopyTo(rightRow); using (IRow currentRow = RightNode.Select(program, rightRow)) { if (currentRow != null) { if (PropagateInsertRight == PropagateAction.Ensure) { RightNode.Update(program, currentRow, newRow, valueFlags, false, uncheckedValue); } } else { RightNode.Insert(program, oldRow, newRow, valueFlags, uncheckedValue); } } } break; } }
public override Expression Compile() { var left = LeftNode[0].Accept(Compiler); var arguments = CompileArguments(); Right = RightNode.Accept(Compiler); var argumentKinds = ArgumentsNode.Select(node => node.Token.Type.GetArgumentKind()); var argumentVars = CreateArgumentVariables(); invocationArguments = argumentKinds.Zip(argumentVars, (kind, arg) => new InvocationArgument(kind, arg)).ToArray(); var argumentVarsAssignment = ArgumentCount == 0 ? (Expression)Empty() : Block(argumentVars.Zip(arguments, Assign)); return(Block( typeof(iObject), new[] { instance }.Concat(argumentVars), Assign(instance, left), argumentVarsAssignment, base.Compile() )); }
public void AddNode(string name, T new_value) { if (new_value.CompareTo(Value) < 0) { if (LeftNode == null) { LeftNode = new BinaryNode <T>(new_value); LeftNode.Value = new_value; } else { LeftNode.AddNode(name, new_value); } } else { if (RightNode == null) { RightNode = new BinaryNode <T>(new_value); RightNode.Value = new_value; } else { RightNode.AddNode(name, new_value); } } }
public void AddNode(int number) { if (number < this.Number) { LeftChilds++; if (LeftNode == null) { LeftNode = new Node(number); } else { LeftNode.AddNode(number); } } // skip when number == Number else if (number > this.Number) { RightChilds++; if (RightNode == null) { RightNode = new Node(number); } else { RightNode.AddNode(number); } } }
public void insertInOrder(int d) { if (d <= Data) { if (LeftNode == null) { LeftNode = new TreeNode(d); } else { LeftNode.insertInOrder(d); } } else { if (RightNode == null) { RightNode = new TreeNode(d); } else { RightNode.insertInOrder(d); } } Size++; }
public void InsertInOrder(T newNodeData) { var comparison = newNodeData.CompareTo(Data); if (comparison <= 0) { if (LeftNode == null) { SetLeftChild(new TreeNode <T>(newNodeData)); } else { LeftNode.InsertInOrder(newNodeData); } } else { if (RightNode == null) { SetRightChild(new TreeNode <T>(newNodeData)); } else { RightNode.InsertInOrder(newNodeData); } } }
public List <bool> TraverseTree(char character, List <bool> data) { if (!isBranch()) { if (character == this.Character) { return(data); } else { return(null); } } else { List <bool> left = data.ToArray().ToList(); List <bool> right = data.ToArray().ToList(); left.Add(true); right.Add(false); return(RightNode.TraverseTree(character, right) ?? LeftNode.TraverseTree(character, left)); } }
internal void PrintTree(Node MarkNode = null, int Level = 0, String Label = "L") { string Info = ""; if (this == MarkNode) { Info = " (mark)"; } Console.WriteLine( "{0}- {1}:{2}{3}", new String(' ', Level * 2), Label, this, Info ); if (LeftNode != null) { LeftNode.PrintTree(MarkNode, Level + 1, "L"); } if (RightNode != null) { RightNode.PrintTree(MarkNode, Level + 1, "R"); } }
//----------------INSERT NODE----------::START::----------------------------------------------------------------------------------- public void InsertNode(int InsertedData) { if (InsertedData < Data) { if (LeftNode == null) { LeftNode = new BinaryNode(InsertedData);//Crates Node when it finds the correct place } else { //Looping - Rekrusion LeftNode.InsertNode(InsertedData);//Traverse through all nodes till it finds the last node and make the inserted node child //Searching for the coorect place of the Node and when it finds it "Creates the Node - Its the If LeftNode = null" } } else if (InsertedData > Data)//If its bigger than the Data "RIGHT" { if (RightNode == null) { RightNode = new BinaryNode(InsertedData); } else { RightNode.InsertNode(InsertedData); } } }
public void Insert(Movie myMovie) { //Lexographically, if the new node is equal to or greater than the current node if (string.Compare(myMovie.Title, this.Title) == 0 || string.Compare(myMovie.Title, this.Title) == 1) { if (RightNode == null) { RightNode = myMovie; } else { RightNode.Insert(myMovie); } } else { if (LeftNode == null) { LeftNode = myMovie; } else { LeftNode.Insert(myMovie); } } }
public void Remove(IBinaryTreeNode <TItem> node, IBinaryTreeNode <TItem> parent) { if (node.Item.CompareTo(Item) < 0) { LeftNode?.Remove(node, this); } else if (node.Item.CompareTo(Item) > 0) { RightNode?.Remove(node, this); } else { if (LeftNode != null && RightNode != null) { parent.RightNode = MinItem; } else if (parent.LeftNode == this) { parent.LeftNode = LeftNode ?? RightNode; } else if (parent.RightNode == this) { parent.RightNode = LeftNode ?? RightNode; } } }
public BinaryTree <TValue> Insert(TValue value) { if (value.CompareTo(Value) >= 0) { if (RightNode == null) { RightNode = new BinaryTree <TValue>(value); return(this); } if (value.CompareTo(Value) == 0) { var temp = new BinaryTree <TValue>(value) { RightNode = RightNode }; RightNode = temp; return(this); } RightNode.Insert(value); return(this); } if (LeftNode == null) { LeftNode = new BinaryTree <TValue>(value); return(this); } LeftNode.Insert(value); return(this); }
//INSERT NODE public void Insert(IComparable insertValue) { if (insertValue.CompareTo(Data) < 0) { if (LeftNode == null) { LeftNode = new TreeNode <T>(insertValue); } else { LeftNode.Insert(insertValue); } } else if (insertValue.CompareTo(Data) > 0) { if (RightNode == null) { RightNode = new TreeNode <T>(insertValue); } else { RightNode.Insert(insertValue); } } }
protected void ValidatePredicate(Program program, IRow row) { if (EnforcePredicate) { bool rightNodeValid = false; try { RightNode.Insert(program, null, row, null, false); rightNodeValid = true; RightNode.Delete(program, row, false, false); } catch (DataphorException exception) { if ((exception.Severity != ErrorSeverity.User) && (exception.Severity != ErrorSeverity.Application)) { throw; } } if (rightNodeValid) { throw new RuntimeException(RuntimeException.Codes.RowViolatesDifferencePredicate, ErrorSeverity.User); } } }
protected override LinqExpression BuildLinqExpression() { var leftOperandExpression = LeftNode.GetEvaluationLinqExpression(); var rightOperandExpression = RightNode.GetEvaluationLinqExpression(); var variableLeft = LinqExpression.Variable(typeof(object)); var variableEvaluatedResult = LinqExpression.Variable(typeof(object)); return(LinqExpression.Block( typeof(object), new[] { variableLeft, variableEvaluatedResult }, LinqExpressionHelper.ExpressionCallThrowIfCancellationRequested, LinqExpression.Assign(variableLeft, leftOperandExpression), LinqExpression.IfThen( LinqExpression.Not( LinqExpression.Call( LinqExpression.Constant(Operator), LinqExpressionHelper.MethodInfoBinaryOperatorEvaluateLhs, LinqExpressionHelper.ExpressionParameterContext, variableLeft, variableEvaluatedResult)), LinqExpression.Assign( variableEvaluatedResult, LinqExpression.Call( LinqExpression.Constant(Operator), LinqExpressionHelper.MethodInfoBinaryOperatorEvaluate, LinqExpressionHelper.ExpressionParameterContext, variableLeft, rightOperandExpression))), variableEvaluatedResult)); }
/// <summary> /// 不包含 末节的树 /// </summary> /// <param name="parentId"></param> /// <param name="allList"></param> /// <param name="chk"></param> /// <returns></returns> private List <RightNode> createTreeNoLast(long parentId, List <Epm_Plan> allList, string chk = "") { List <RightNode> list = new List <RightNode>(); var childList = allList.Where(i => i.ParentId == parentId).ToList(); //有子权限 if (childList != null && childList.Any()) { foreach (var item in childList) { RightNode node = new RightNode(); node.checkboxValue = item.Id.ToString(); node.@checked = false; if (item.Id.ToString() == chk) { node.@checked = true; } node.data = new { id = item.Id.ToString() }; node.name = item.Name; node.spread = true; var iteratorList = createTreeNoLast(item.Id, allList, chk); node.children = iteratorList; var ccp = allList.Where(i => i.ParentId == item.Id).ToList(); if (ccp.Count() < 1) { continue; } list.Add(node); } } return(list); }
public override dynamic Evaluate(SymbolTable table) { var _value = (int)((uint)LeftNode.Evaluate(table) >> RightNode.Evaluate(table)); var _leftId = GetLeftValue(); table.AddSymbol(_leftId.Name, _value); return(_value); }