public IEnumerable <bool> Transform(SetNode item) { throw new NotImplementedException(); }
public void Transform(SetNode item) { TransformASTNode(item); }
public void Transform(SetNode item, bool inner = false) { SetTrim(); }
public void Visit(SetNode node) { node.Value?.Accept(this); node.Accept(_visitor); }
public void SetNodeTest_MixedCompatibleTypes() { StreamLocation expectedLocation = new StreamLocation(3, 2, 1); ISet<SimpleValueNode> testSet = new HashSet<SimpleValueNode>() { new NumberNode("34", new StreamLocation()), new NumberNode("3.4", new StreamLocation()), new NumberNode("34e-2", new StreamLocation()), }; ValueNode sut = new SetNode(testSet, expectedLocation); Assert.AreEqual(TNode.SET, sut.NodeType); Assert.AreEqual(expectedLocation, sut.Location); Assert.IsTrue(sut.Description.Contains("SET")); Assert.AreEqual(FieldValueType.FLOAT, sut.ValueType); Assert.IsNull(sut.SubExpression); Assert.AreEqual(testSet, ((SetNode)sut).GetSet()); }
/// <summary> /// Set clear. /// </summary> public void Clear() { root = null; Count = 0; }
public SetSymbol GetSetSymbol(SetNode node) { return((SetSymbol)symbols[node.Value]); }
protected int ReferencedRelationAttributeCount(SetNode setNode) { var attributeList = AllAttributes.First(l => l.Contains(setNode.Value)); return(attributeList.Count); }
public void SearchAndAddToParentNode(Node parentNode, string folder, Action <string> onFileDetected = null) { if (!Directory.Exists(folder)) { return; } var dirInfo = new DirectoryInfo(folder); var setDefPath = Path.Combine(folder, @"set.def"); if (File.Exists(setDefPath)) { onFileDetected?.Invoke(setDefPath); var setDef = SetDef.RestoreFrom(setDefPath); foreach (var block in setDef.Blocks) { var setNode = new SetNode(block, folder, parentNode); if (0 < setNode.ChildNodeList.Count) { parentNode.ChildNodeList.Add(setNode); } } return; } else { //---------------- var fileInfos = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly) .Where((fileInfo) => SearchExtensions.Any(ext => (Path.GetExtension(fileInfo.Name).ToLower() == ext))); var anyDtxFile = false; foreach (var fileInfo in fileInfos) { var vpath = fileInfo.FullName; onFileDetected?.Invoke(vpath); try { var music = new MusicNode(vpath, parentNode); parentNode.ChildNodeList.Add(music); anyDtxFile = true; } catch { } } if (anyDtxFile) { return; } } foreach (var subDirInfo in dirInfo.GetDirectories()) { var DTXFILES = "dtxfiles."; var boxDefPath = Path.Combine(subDirInfo.FullName, @"box.def"); if (subDirInfo.Name.ToLower().StartsWith(DTXFILES)) { var boxNode = new BoxNode(subDirInfo.Name.Substring(DTXFILES.Length), parentNode); parentNode.ChildNodeList.Add(boxNode); var backNode = new BackNode(boxNode); boxNode.ChildNodeList.Add(backNode); SearchAndAddToParentNode(boxNode, subDirInfo.FullName, onFileDetected); } else if (File.Exists(boxDefPath)) { var boxNode = new BoxNode(boxDefPath, parentNode); parentNode.ChildNodeList.Add(boxNode); var backNode = new BackNode(boxNode); boxNode.ChildNodeList.Add(backNode); SearchAndAddToParentNode(boxNode, subDirInfo.FullName, onFileDetected); } else { SearchAndAddToParentNode(parentNode, subDirInfo.FullName, onFileDetected); } } }
public void Transform(SetNode item) { throw new NotImplementedException(); }
private void SetTail(SetNode node, SetNode tail) { SetNode rep = GetRepresentative(node); rep.representative = tail; }
private SetNode GetTail(SetNode node) { return(GetRepresentative(node).representative); }
public void SetNodeTest_MixedIncompatibleTypes() { StreamLocation expectedLocation = new StreamLocation(3, 2, 1); ISet<SimpleValueNode> testSet = new HashSet<SimpleValueNode>() { new NumberNode("34", new StreamLocation()), new StringNode("3.4", new StreamLocation()), new NumberNode("34e-2", new StreamLocation()), }; ValueNode sut = new SetNode(testSet, expectedLocation); }
/// <summary> /// Intersects two nodes. If /// </summary> /// <param name="A"></param> /// <param name="B"></param> /// <returns></returns> public static SetNode Intersect(SetNode A, SetNode B) { if (A.Type == SetNode.NodeType.OPERATOR || B.Type == SetNode.NodeType.OPERATOR) { return(new OperatorSet(OperatorSet.OperatorType.INTERSECTION, A, B)); } var(goodAPieces, badAPieces) = GatherEvaluablePieces(A as Set); var(goodBPieces, badBPieces) = GatherEvaluablePieces(B as Set); if (goodAPieces.Count * goodBPieces.Count == 0) { return(new OperatorSet(OperatorSet.OperatorType.INTERSECTION, A, B)); } var newPieces = new List <Piece>(); foreach (var goodAPiece in goodAPieces) { foreach (var goodBPiece in goodBPieces) { var piece = PieceFunctions.Intersect(goodAPiece, goodBPiece); if (!(piece is null) && PieceFunctions.IsPieceCorrect(piece)) { newPieces.Add(piece); } } } var union = UniteList(newPieces); var badA = new Set { Pieces = badAPieces }; var badB = new Set { Pieces = badBPieces }; if (union.Count == 0) { if (badA.IsEmpty() || badB.IsEmpty()) { return(new Set()); } else { return(new OperatorSet(OperatorSet.OperatorType.INTERSECTION, badA, badB)); } } var united = new Set { Pieces = union }; if (badBPieces.Count + badAPieces.Count == 0) { return(united); } /* * A = A1 or A2 (A1 - good, A2 - bad) * B = B1 or B2 (B1 - good, B2 - bad) * A & B = (A1 & B1) | (A1 & B2) | (A2 & B1) | (A2 & B2) */ var goodA = new Set { Pieces = goodAPieces }; var goodB = new Set { Pieces = goodBPieces }; return(OperatorSet.Or( united, // A1 & B1 OperatorSet.Or( OperatorSet.And( // A2 & B2 badA, badB ), OperatorSet.Or( OperatorSet.And(badA, goodB), // A2 & B1 OperatorSet.And(badB, goodA) // A1 & B2 )))); }
public SetNodeContainer(ParseData parseData) : base(parseData, true) { Node = new SetNode <string>(parseData.Source, parseData.Value); }
public virtual void Visit(SetNode node) { node.Variable.Accept(this); node.Value.Accept(this); node.Accept(_visitor); }
/// <summary> /// Remove element from set. /// </summary> /// <param name="value">Element`s value</param> /// <returns>True - succeded, false - otherwise</returns> public bool Remove(T value) { SetNode parent = null; var elementForDeletion = GetElementInTreeAndParent(value, ref parent); if (elementForDeletion == null) { return(false); } Count--; if (elementForDeletion.leftChild == null && elementForDeletion.rightChild == null) { if (root == elementForDeletion) { root = null; return(true); } SetChild(parent, elementForDeletion, null); elementForDeletion = null; return(true); } if (elementForDeletion.leftChild == null && elementForDeletion.rightChild != null) { if (root == elementForDeletion) { root = elementForDeletion.rightChild; elementForDeletion = null; return(true); } SetChild(parent, elementForDeletion, elementForDeletion.rightChild); elementForDeletion = null; return(true); } if (elementForDeletion.rightChild == null && elementForDeletion.leftChild != null) { if (root == elementForDeletion) { root = elementForDeletion.leftChild; elementForDeletion = null; return(true); } SetChild(parent, elementForDeletion, elementForDeletion.leftChild); elementForDeletion = null; return(true); } var parentOfChangeElement = elementForDeletion; var changeElement = FindLeftMax(elementForDeletion, ref parentOfChangeElement); if (root == elementForDeletion) { if (elementForDeletion.leftChild == changeElement) { root = changeElement; changeElement.rightChild = elementForDeletion.rightChild; elementForDeletion = null; return(true); } root = changeElement; parentOfChangeElement.rightChild = changeElement.leftChild; changeElement.leftChild = elementForDeletion.leftChild; changeElement.rightChild = elementForDeletion.rightChild; elementForDeletion = null; return(true); } if (elementForDeletion.leftChild == changeElement) { SetChild(parent, elementForDeletion, changeElement); changeElement.rightChild = elementForDeletion.rightChild; elementForDeletion = null; return(true); } parentOfChangeElement.rightChild = changeElement.leftChild; SetChild(parent, elementForDeletion, changeElement); changeElement.leftChild = elementForDeletion.leftChild; changeElement.rightChild = elementForDeletion.rightChild; elementForDeletion = null; return(true); }
public Set(SetNode content) => Content = content;
public void SetNodeTest_Empty() { StreamLocation expectedLocation = new StreamLocation(3, 2, 1); ISet<SimpleValueNode> testSet = new HashSet<SimpleValueNode>(); ValueNode sut = new SetNode(testSet, expectedLocation); Assert.AreEqual(TNode.SET, sut.NodeType); Assert.AreEqual(expectedLocation, sut.Location); Assert.IsTrue(sut.Description.Contains("SET")); Assert.AreEqual(FieldValueType.NONE, sut.ValueType); Assert.IsNull(sut.SubExpression); Assert.AreEqual(testSet, ((SetNode)sut).GetSet()); }