/* * The subroutine of DFS. NOTE: the set is used to distinguish between 1st * and 2nd round of DFS. set == null: finished vertices are stored (1st * round). set != null: all vertices found will be saved in the set (2nd * round) */ private void dfsVisit(DirectedGraph graph, VertexData vertexData, SupportClass.SetSupport vertices) { System.Collections.ArrayList stack = new System.Collections.ArrayList(); stack.Add(vertexData); while (!(stack.Count == 0)) { VertexData data = (VertexData)SupportClass.StackSupport.Pop(stack); if (!data.m_discovered) { data.m_discovered = true; if (vertices != null) { vertices.Add(data.m_vertex); } // TODO: other way to identify when this vertex is finished!? stack.Add(new VertexData(this, data, true, true)); // follow all edges System.Collections.IEnumerator iter = graph.outgoingEdgesOf(data.m_vertex).GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (iter.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" DirectedEdge edge = (DirectedEdge)iter.Current; VertexData targetData = (VertexData)m_vertexToVertexData[edge.Target]; if (!targetData.m_discovered) { // the "recursion" stack.Add(targetData); } } } else if (data.m_finished) { if (vertices == null) { // see TODO above m_orderedVertices.Insert(0, data.m_vertex); } } } }
/// /// <summary> * </summary> /// protected internal ExtensionFileFilter(string fileExtension) { if (fileExtension != null) { VString list = new VString(StringUtil.tokenize(fileExtension, ",", false)); m_extension = new SupportClass.HashSetSupport <string>(); for (int i = 0; i < list.Count; i++) { string st = list.stringAt(i); if (st.StartsWith(".")) { st = st.Substring(1); } st = st.ToLower(); m_extension.Add(st); } } }
/// <summary> {@inheritDoc}</summary> protected internal override void encounterVertexAgain(System.Object vertex, Edge edge) { base.encounterVertexAgain(vertex, edge); int i = m_path.IndexOf(vertex); if (i > -1) { if (m_cycleSet == null) { // we're doing yes/no cycle detection throw new CycleDetectedException(); } for (; i < m_path.Count; ++i) { m_cycleSet.Add(m_path[i]); } } }
/// /// <summary> * get the list of Device/@DeviceIDs strings as a set /// * </summary> /// * <returns> the set of DeviceIDs, null if no Device is specified </returns> /// public virtual SupportClass.SetSupport <string> getDeviceIDSet() { int size = 0; SupportClass.SetSupport <string> @set = null; VElement v = getChildElementVector(ElementName.DEVICE, null); if (v != null) { size = v.Count; @set = size == 0 ? null : new SupportClass.HashSetSupport <string>(); for (int i = 0; i < size; i++) { string qeid = ((JDFDevice)v[i]).getDeviceID(); if (!isWildCard(qeid)) { @set.Add(qeid); } } } return(@set != null && @set.Count > 0 ? @set : null); }
/// /// /// <summary> * gets the sum of all matching tags, with the assumpzion that no condition defaults to good /// * </summary> /// * <param name="poolParent"> </param> /// * <param name="attName"> </param> /// * <param name="vPart"> </param> /// * <returns> the sum /// * </returns> /// public static double getAmountPoolSumDouble(IAmountPoolContainer poolParent, string attName, VJDFAttributeMap vPart) { VJDFAttributeMap vPartLocal = vPart; if (vPartLocal == null) { vPartLocal = poolParent.getPartMapVector(); } if (poolParent.hasAttribute(attName)) { return(poolParent.getRealAttribute(attName, null, 0)); } VJDFAttributeMap vm = vPartLocal == null ? null : new VJDFAttributeMap(vPartLocal); JDFResource linkRoot = poolParent.getLinkRoot(); if (linkRoot != null && vm != null) { SupportClass.SetSupport <string> @set = linkRoot.getPartIDKeys().getSet(); @set.Add(AttributeName.CONDITION); // retain good / waste vm.reduceMap(@set); } if (vm == null) { vm = new VJDFAttributeMap(); vm.Add((JDFAttributeMap)null); } double dd = 0; JDFAmountPool ap = poolParent.getAmountPool(); if (ap == null) { return(poolParent.getRealAttribute(attName, null, 0.0)); } VElement vParts = ap.getChildElementVector(ElementName.PARTAMOUNT, null); if (vParts.IsEmpty()) { return(poolParent.getRealAttribute(attName, null, 0.0)); } bool isWaste = vPartLocal != null && vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "Waste")); if (!isWaste && (vPartLocal == null || !vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*")))) { vPartLocal = new VJDFAttributeMap(vPartLocal); vPartLocal.Add(new JDFAttributeMap(AttributeName.CONDITION, "Good")); } for (int j = 0; j < vParts.Count; j++) { JDFPartAmount pa = (JDFPartAmount)vParts[j]; VJDFAttributeMap partMapVector = pa.getPartMapVector(); if (isWaste) { bool hasCondition = partMapVector.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*")); if (!hasCondition) { continue; } } if (!partMapVector.overlapsMap(vm)) { continue; } string ret = null; ret = pa.getAttribute(attName, null, null); if (ret == null) { ret = poolParent.getAttribute(attName, null, null); } dd += StringUtil.parseDouble(ret, 0.0); } return(dd); }
/// <seealso cref="TraversalListenerAdapter.vertexTraversed(Object)"> /// </seealso> public override void vertexTraversed(VertexTraversalEvent e) { System.Object v = e.getVertex(); m_currentConnectedSet.Add(v); Enclosing_Instance.m_vertexToConnectedSet[v] = m_currentConnectedSet; }