/// <summary> /// Removes all objects from the set. /// </summary> public sealed override void Clear() { lock (_syncRoot) { _basisSet.Clear(); } }
/// <summary> /// Performs an "intersection" of the two sets, where only the elements /// that are present in both sets remain. That is, the element is included if it exists in /// both sets. The <c>Intersect()</c> operation does not modify the input sets. It returns /// a <c>Clone()</c> of this set with the appropriate elements removed. /// </summary> /// <param name="a">A set of elements.</param> /// <returns>The intersection of this set with <c>a</c>.</returns> public Set Intersect(Set a) { Set resultSet = (Set)this.Clone(); if (a != null) { resultSet.RetainAll(a); } else { resultSet.Clear(); } return(resultSet); }
/// <summary> /// Performs an "intersection" of the two sets, where only the elements /// that are present in both sets remain. That is, the element is included only if it exists in /// both <c>a</c> and <c>b</c>. Neither input object is modified by the operation. /// The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <c>null</c>) containing the /// elements from the intersect operation. /// </summary> /// <param name="a">A set of elements.</param> /// <param name="b">A set of elements.</param> /// <returns>The intersection of the two input sets. <c>null</c> if both sets are <c>null</c>.</returns> public static Set Intersect(Set a, Set b) { if (a == null && b == null) { return(null); } else if (a == null) { Set resultSet = (Set)((Set)b).Clone(); resultSet.Clear(); return(resultSet); } else if (b == null) { Set resultSet = (Set)((Set)a).Clone(); resultSet.Clear(); return(resultSet); } else { return(a.Intersect(b)); } }
private void AddParentsOfNeededGraphElements(Set<INode> latelyAddedNodes) { Set<INode> newlyAddedNodes = new Set<INode>(); // wavefront algorithm, in the following step all nodes added by the previous step are inspected, // until the wave collapses cause no not already added node is added any more while(latelyAddedNodes.Count > 0) { foreach(INode node in latelyAddedNodes) { bool parentFound = false; foreach(GroupNodeType groupNodeType in ycompClient.dumpInfo.GroupNodeTypes) { foreach(IEdge edge in node.Incoming) { INode parent = edge.Source; if(!groupNodeType.NodeType.IsMyType(parent.Type.TypeID)) continue; GroupMode grpMode = groupNodeType.GetEdgeGroupMode(edge.Type, node.Type); if((grpMode & GroupMode.GroupOutgoingNodes) == 0) continue; if(!excludedGraphNodesIncluded.ContainsKey(parent)) { newlyAddedNodes.Add(parent); ycompClient.AddNode(parent); excludedGraphNodesIncluded.Add(parent, true); ycompClient.AddEdge(edge); if(!excludedGraphEdgesIncluded.ContainsKey(edge)) excludedGraphEdgesIncluded.Add(edge, true); } parentFound = true; } if(parentFound) break; foreach(IEdge edge in node.Outgoing) { INode parent = edge.Target; if(!groupNodeType.NodeType.IsMyType(parent.Type.TypeID)) continue; GroupMode grpMode = groupNodeType.GetEdgeGroupMode(edge.Type, node.Type); if((grpMode & GroupMode.GroupIncomingNodes) == 0) continue; if(!excludedGraphNodesIncluded.ContainsKey(parent)) { newlyAddedNodes.Add(parent); ycompClient.AddNode(parent); excludedGraphNodesIncluded.Add(parent, true); ycompClient.AddEdge(edge); if(!excludedGraphEdgesIncluded.ContainsKey(edge)) excludedGraphEdgesIncluded.Add(edge, true); } parentFound = true; } if(parentFound) break; } } Set<INode> tmp = latelyAddedNodes; latelyAddedNodes = newlyAddedNodes; newlyAddedNodes = tmp; newlyAddedNodes.Clear(); } }