Beispiel #1
0
        /// <summary> Finds a 2-approximation for a minimal vertex cover of the specified
        /// graph. The algorithm promises a cover that is at most double the size
        /// of a minimal cover. The algorithm takes O(|E|) time.
        ///
        /// <p>
        /// For more details see Jenny Walter, CMPU-240: Lecture notes for Language
        /// Theory and Computation, Fall 2002, Vassar College, <a
        /// href="http://www.cs.vassar.edu/~walter/cs241index/lectures/PDF/approx.pdf">
        ///
        /// http://www.cs.vassar.edu/~walter/cs241index/lectures/PDF/approx.pdf</a>.
        /// </p>
        ///
        /// </summary>
        /// <param name="g">the graph for which vertex cover approximation is to be found.
        ///
        /// </param>
        /// <returns> a set of vertices which is a vertex cover for the specified
        /// graph.
        /// </returns>
        public virtual SupportClass.SetSupport find2ApproximationCover(Graph g)
        {
            // C <-- {}
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            SupportClass.SetSupport cover = new SupportClass.HashSetSupport();

            // G'=(V',E') <-- G(V,E)
            Subgraph sg = new Subgraph(g, null, null);

            // while E' is non-empty
            while (sg.edgeSet().Count > 0)
            {
                // let (u,v) be an arbitrary edge of E'
                //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'"
                Edge e = (Edge)sg.edgeSet().GetEnumerator().Current;

                // C <-- C U {u,v}
                System.Object u = e.Source;
                System.Object v = e.Target;
                cover.Add(u);
                cover.Add(v);

                // remove from E' every edge incident on either u or v
                sg.removeVertex(u);
                sg.removeVertex(v);
            }

            return(cover);            // return C
        }
Beispiel #2
0
        private void  cleanReservedMessages()
        {
            lock (this)
            {
                System.Collections.IEnumerator it     = new SupportClass.HashSetSupport(myAvailableMessages.Keys).GetEnumerator();
                System.Collections.IList       remove = new System.Collections.ArrayList();
                while (it.MoveNext())
                {
                    System.String         ackId = (System.String)it.Current;
                    ExpiringTransportable et    = (ExpiringTransportable)myAvailableMessages[ackId];
                    if ((System.DateTime.Now.Ticks - 621355968000000000) / 10000 > et.expiryTime)
                    {
                        //myAvailableMessages.Remove(it.Current);
                        remove.Add(it.Current);

                        //send to an Application
                        NuGenTransportable out_Renamed = myContext.Router.processMessage(et.transportable);
                        sendAppResponse(out_Renamed);
                    }

                    foreach (object item in remove)
                    {
                        myAvailableMessages.Remove(item);
                    }
                }
            }
        }
Beispiel #3
0
		public static System.String unescape(System.String text, NuGenEncodingCharacters encChars)
		{
			System.Text.StringBuilder result = new System.Text.StringBuilder();
			int textLength = text.Length;
			System.Collections.Hashtable esc = getEscapeSequences(encChars);
			SupportClass.SetSupport keys = new SupportClass.HashSetSupport(esc.Keys);
			System.String escChar = System.Convert.ToString(encChars.EscapeCharacter);
			int position = 0;
			while (position < textLength)
			{
				System.Collections.IEnumerator it = keys.GetEnumerator();
				bool isReplaced = false;
				while (it.MoveNext() && !isReplaced)
				{
					System.String seq = (System.String) it.Current;
					System.String val = (System.String) esc[seq];
					int seqLength = seq.Length;
					if (position + seqLength <= textLength)
					{
						if (text.Substring(position, (position + seqLength) - (position)).Equals(seq))
						{
							result.Append(val);
							isReplaced = true;
							position = position + seq.Length;
						}
					}
				}
				if (!isReplaced)
				{
					result.Append(text.Substring(position, ((position + 1)) - (position)));
					position++;
				}
			}
			return result.ToString();
		}
Beispiel #4
0
        /// <summary> Populates the given Segment object with data from the given XML Element.</summary>
        /// <throws>  HL7Exception if the XML Element does not have the correct name and structure </throws>
        /// <summary>      for the given Segment, or if there is an error while setting individual field values.
        /// </summary>
        public virtual void  parse(Segment segmentObject, System.Xml.XmlElement segmentElement)
        {
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element && !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int           fieldNum       = System.Int32.Parse(fieldNumString);
                        parseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, Factory);
            }
        }
Beispiel #5
0
        public static System.String escape(System.String text, NuGenEncodingCharacters encChars)
        {
            System.Text.StringBuilder result = new System.Text.StringBuilder();
            int textLength = text.Length;

            System.Collections.Hashtable esc  = getEscapeSequences(encChars);
            SupportClass.SetSupport      keys = new SupportClass.HashSetSupport(esc.Keys);
            System.String escChar             = System.Convert.ToString(encChars.EscapeCharacter);
            int           position            = 0;

            while (position < textLength)
            {
                System.Collections.IEnumerator it = keys.GetEnumerator();
                bool isReplaced = false;
                while (it.MoveNext() && !isReplaced)
                {
                    System.String seq = (System.String)it.Current;
                    System.String val = (System.String)esc[seq];
                    if (text.Substring(position, (position + 1) - (position)).Equals(val))
                    {
                        result.Append(seq);
                        isReplaced = true;
                    }
                }
                if (!isReplaced)
                {
                    result.Append(text.Substring(position, ((position + 1)) - (position)));
                }
                position++;
            }
            return(result.ToString());
        }
Beispiel #6
0
        ///
        ///	 <summary> * does this ColorPool have Color elements with identical Name or RawName
        ///	 * eattributes return false if no Color elements with identical Name or
        ///	 * RawName tags exist </summary>
        ///
        public virtual VString getDuplicateColors()
        {
            VElement v = getChildElementVector(ElementName.COLOR, null, null, true, 0, false);

            SupportClass.HashSetSupport <string> vName = new SupportClass.HashSetSupport <string>();
            int     nCols = v.Count;
            VString vRet  = new VString();

            for (int i = 0; i < nCols; i++)
            {
                JDFColor color     = (JDFColor)v[i];
                string   colorName = color.getName();
                if (vName.Contains(colorName))
                {
                    vRet.appendUnique(colorName);
                }
                string rawName = color.get8BitName();
                if (vName.Contains(rawName))
                {
                    vRet.appendUnique(colorName);
                }
                vName.Add(colorName);
                vName.Add(rawName);
            }

            return(vRet.Count == 0 ? null : vRet);
        }
Beispiel #7
0
        /// <summary> Finds a greedy approximation for a minimal vertex cover of a specified
        /// graph. At each iteration, the algorithm picks the vertex with the
        /// highest degree and adds it to the cover, until all edges are covered.
        ///
        /// <p>
        /// The algorithm works on undirected graphs, but can also work on directed
        /// graphs when their edge-directions are ignored. To ignore edge
        /// directions you can use {@link
        /// org._3pq.jgrapht.GraphHelper#undirectedGraph(Graph)} or {@link
        /// org._3pq.jgrapht.graph.AsUndirectedGraph}.
        /// </p>
        ///
        /// </summary>
        /// <param name="g">the graph for which vertex cover approximation is to be found.
        ///
        /// </param>
        /// <returns> a set of vertices which is a vertex cover for the specified
        /// graph.
        /// </returns>
        public virtual SupportClass.SetSupport findGreedyCover(UndirectedGraph g)
        {
            // C <-- {}
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            SupportClass.SetSupport cover = new SupportClass.HashSetSupport();

            // G' <-- G
            UndirectedGraph sg = new UndirectedSubgraph(g, null, null);

            // compare vertices in descending order of degree
            VertexDegreeComparator comp = new VertexDegreeComparator(sg);

            // while G' != {}
            while (sg.edgeSet().Count > 0)
            {
                // v <-- vertex with maximum degree in G'
                System.Object v = SupportClass.CollectionsSupport.Max(sg.vertexSet(), comp);

                // C <-- C U {v}
                cover.Add(v);

                // remove from G' every edge incident on v, and v itself
                sg.removeVertex(v);
            }

            return(cover);
        }
Beispiel #8
0
        /// <summary> Finds the vertex set for the subgraph of all cycles which contain a
        /// particular vertex.
        ///
        /// </summary>
        /// <param name="v">the vertex to test
        ///
        /// </param>
        /// <returns> set of all vertices reachable from v via at least one cycle
        /// </returns>
        public virtual SupportClass.SetSupport findCyclesContainingVertex(System.Object v)
        {
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            SupportClass.SetSupport set_Renamed = new SupportClass.HashSetSupport();
            execute(set_Renamed, v);

            return(set_Renamed);
        }
Beispiel #9
0
 private static void  setGroupSuccessors(System.Collections.IDictionary theSuccessors, System.String theSegName)
 {
     for (System.Collections.IEnumerator it = new SupportClass.HashSetSupport(theSuccessors.Keys).GetEnumerator(); it.MoveNext();)
     {
         StructRef from = (StructRef)it.Current;
         StructRef to   = (StructRef)theSuccessors[from];
         from.setSuccessor(theSegName, to);
     }
     theSuccessors.Clear();
 }
Beispiel #10
0
        public virtual void testReduceMapSet()
        {
            JDFAttributeMap m1 = new JDFAttributeMap("a1", "v1");

            m1.put("a2", "v2");
            JDFAttributeMap m2 = new JDFAttributeMap("a1", "v1");

            SupportClass.HashSetSupport <string> keys = new SupportClass.HashSetSupport <string>();
            keys.Add("a1");
            m1.reduceMap(keys);
            Assert.AreEqual(m1, m2);
        }
 public override string ToString()
 {
     var builder = new StringBuilder();
     System.Collections.IEnumerator keyIterator = new SupportClass.HashSetSupport(table.Keys).GetEnumerator();
     while (keyIterator.MoveNext())
     {
         var key = (QName) keyIterator.Current;
         builder.Append("Dictionary: Global");
         builder.Append(key).Append("=").Append(table[key]).Append("\n");
     }
     return builder.ToString();
 }
Beispiel #12
0
 ///
 ///	 <summary> * create a HashSet from a List (Vector...) </summary>
 ///	 * @param <a> the data typeof the sets
 ///	 *  </param>
 ///	 * <param name="list"> </param>
 ///	 * <returns> a Set created from list </returns>
 ///
 public static SupportClass.SetSupport <a> toHashSet <a>(List <a> list)
 {
     if (list == null)
     {
         return(null);
     }
     SupportClass.SetSupport <a> s = new SupportClass.HashSetSupport <a>();
     for (int i = 0; i < list.Count; i++)
     {
         s.Add(list[i]);
     }
     return(s);
 }
Beispiel #13
0
 ///
 ///	 <summary> * create a HashSet from an Array </summary>
 ///	 * @param <a> the data typeof the sets
 ///	 *  </param>
 ///	 * <param name="l"> </param>
 ///	 * <returns> a Set created from list </returns>
 ///
 public static SupportClass.SetSupport <a> toHashSet <a>(a[] l)
 {
     if (l == null)
     {
         return(null);
     }
     SupportClass.SetSupport <a> s = new SupportClass.HashSetSupport <a>();
     for (int i = 0; i < l.Length; i++)
     {
         s.Add(l[i]);
     }
     return(s);
 }
Beispiel #14
0
        ///
        ///     <summary> * gets a set with all entries of the Vstring
        ///     * @return </summary>
        ///
        public virtual SupportClass.SetSupport <string> getSet()
        {
            // Java to C# Conversion - QUESTION: Need to implement LinkedHashSet?
            SupportClass.HashSetSupport <string> @set = new SupportClass.HashSetSupport <string>(); // new LinkedHashSet<string>();
            IEnumerator <string> it = GetEnumerator();

            while (it.MoveNext())
            {
                @set.Add(it.Current);
            }

            return(@set);
        }
Beispiel #15
0
        public override string ToString()
        {
            var builder = new StringBuilder();

            System.Collections.IEnumerator keyIterator = new SupportClass.HashSetSupport(table.Keys).GetEnumerator();
            while (keyIterator.MoveNext())
            {
                var key = (QName)keyIterator.Current;
                builder.Append("Dictionary: Global");
                builder.Append(key).Append("=").Append(table[key]).Append("\n");
            }
            return(builder.ToString());
        }
Beispiel #16
0
 public virtual void testUniqueID()
 {
     // Java to C# Conversion, Test taking too long, reduce count from original 200,000 for now
     SupportClass.HashSetSupport m = new SupportClass.HashSetSupport();
     for (int i = 0; i < 1000; i++)
     {
         string s = JDFElement.uniqueID(0);
         if (m.Contains(s))
         {
             Assert.Fail("oops");
         }
         m.Add(s);
     }
 }
Beispiel #17
0
        ///
        ///	 <summary> * get refElements
        ///	 *  </summary>
        ///	 * <param name="vDoneRefs"> used internally for recursion </param>
        ///	 * <param name="bRecurse"> if true, also return recursively linked IDs </param>
        ///	 * <returns> HashSet: the vector of referenced resource IDs </returns>
        ///
        public override SupportClass.HashSetSupport getAllRefs(SupportClass.HashSetSupport vDoneRefs, bool bRecurse)
        {
            SupportClass.HashSetSupport vDoneRefsLocal = vDoneRefs;

            VElement vResources = getPoolChildren(null, null, null);
            int      size       = vResources.Count;

            for (int i = 0; i < size; i++)
            {
                JDFResource r = (JDFResource)vResources[i];
                vDoneRefsLocal = r.getResourceRoot().getAllRefs(vDoneRefsLocal, bRecurse);
            }

            return(vDoneRefsLocal);
        }
 public override string ToString()
 {
     var builder = new StringBuilder();
     foreach (QName type in dictionary.Keys)
     {
         builder.Append("Dictionary: Type=" + type);
         System.Collections.IDictionary templateMap = dictionary[type];
         System.Collections.IEnumerator keyIterator = new SupportClass.HashSetSupport(templateMap.Keys).GetEnumerator();
         while (keyIterator.MoveNext())
         {
             System.Object key = keyIterator.Current;
             builder.Append(key).Append("=").Append(templateMap[key]).Append("\n");
         }
     }
     return builder.ToString();
 }
Beispiel #19
0
        //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
        public static bool hashMapEquals(System.Collections.Hashtable a, System.Collections.Hashtable b)
        {
            if (a.Count != b.Count)
            {
                return(false);
            }
            else if (a is OrderedMap != b is OrderedMap)
            {
                return(false);
            }
            else
            {
                for (Object keyA: a.keySet())
                {
                    //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
                    if (!equals(a[keyA], b[keyA]))
                    {
                        return(false);
                    }
                }

                if (a is OrderedMap && b is OrderedMap)
                {
                    //UPGRADE_TODO: Method 'java.util.HashMap.keySet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapkeySet'"
                    System.Collections.IEnumerator ea = new SupportClass.HashSetSupport(a.Keys).GetEnumerator();
                    //UPGRADE_TODO: Method 'java.util.HashMap.keySet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapkeySet'"
                    System.Collections.IEnumerator eb = new SupportClass.HashSetSupport(b.Keys).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 (ea.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'"
                        System.Object keyA = ea.Current;
                        //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'"
                        System.Object keyB = eb.Current;

                        if (!keyA.Equals(keyB))
                        {
                            //must use built-in equals for keys, as that's what HashMap uses
                            return(false);
                        }
                    }
                }

                return(true);
            }
        }
        public override string ToString()
        {
            var builder = new StringBuilder();

            foreach (QName type in dictionary.Keys)
            {
                builder.Append("Dictionary: Type=" + type);
                System.Collections.IDictionary templateMap = dictionary[type];
                System.Collections.IEnumerator keyIterator = new SupportClass.HashSetSupport(templateMap.Keys).GetEnumerator();
                while (keyIterator.MoveNext())
                {
                    System.Object key = keyIterator.Current;
                    builder.Append(key).Append("=").Append(templateMap[key]).Append("\n");
                }
            }
            return(builder.ToString());
        }
Beispiel #21
0
        public static System.String escape(System.String text, EncodingCharacters encChars)
        {
            //First, take all special characters and replace them with something that is garbled
            for (int i = 0; i < SPECIAL_ENCODING_VALUES.Length; i++)
            {
                string specialValues = SPECIAL_ENCODING_VALUES[i];
                text = text.Replace(specialValues, EncodeSpecialCharacters(i.ToString()));
            }
            //Encode each escape character
            System.Collections.Hashtable esc    = getEscapeSequences(encChars);
            System.Text.StringBuilder    result = new System.Text.StringBuilder();
            SupportClass.SetSupport      keys   = new SupportClass.HashSetSupport(esc.Keys);
            System.String escChar  = System.Convert.ToString(encChars.EscapeCharacter);
            int           position = 0;

            while (position < text.Length)
            {
                System.Collections.IEnumerator it = keys.GetEnumerator();
                bool isReplaced = false;
                while (it.MoveNext() && !isReplaced)
                {
                    System.String seq = (System.String)it.Current;
                    System.String val = (System.String)esc[seq];
                    if (text.Substring(position, 1).Equals(val))
                    {
                        result.Append(seq);
                        isReplaced = true;
                    }
                }
                if (!isReplaced)
                {
                    result.Append(text.Substring(position, 1));
                }
                position++;
            }

            //Replace each garbled entry with the correct special value
            for (int i = 0; i < SPECIAL_ENCODING_VALUES.Length; i++)
            {
                string specialValues = SPECIAL_ENCODING_VALUES[i];
                result.Replace(EncodeSpecialCharacters(i.ToString()), specialValues);
            }
            return(result.ToString());
        }
Beispiel #22
0
        }         // end getGDSkey

        //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
        private void  checkGDSkeys(Grib1GridDefinitionSection gds, System.Collections.Hashtable gdsCounter)
        {
            // lat/lon grids can have > 1 GDSs
            if (gds.GridType == 0 || gds.GridType == 4)
            {
                return;
            }
            System.String bestKey = "";
            int           count   = 0;

            // find bestKey with the most counts
            //UPGRADE_TODO: Method 'java.util.HashMap.keySet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapkeySet'"
            //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'"
            for (System.Collections.IEnumerator it = new SupportClass.HashSetSupport(gdsCounter.Keys).GetEnumerator(); it.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'"
                System.String key = (System.String)it.Current;
                //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
                int gdsCount = System.Int32.Parse((System.String)gdsCounter[key]);
                if (gdsCount > count)
                {
                    count   = gdsCount;
                    bestKey = key;
                }
            }
            // remove best key from gdsCounter, others will be removed from gdsHM
            gdsCounter.Remove(bestKey);
            // remove all GDSs using the gdsCounter
            //UPGRADE_TODO: Method 'java.util.HashMap.keySet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapkeySet'"
            //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'"
            for (System.Collections.IEnumerator it = new SupportClass.HashSetSupport(gdsCounter.Keys).GetEnumerator(); it.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'"
                System.String key = (System.String)it.Current;
                gdsHM.Remove(key);
            }
            // reset GDS keys in products too
            for (int i = 0; i < products.Count; i++)
            {
                Grib1Product g1p = (Grib1Product)products[i];
                g1p.GDSkey = bestKey;
            }
            return;
        }         // end checkGDSkeys
Beispiel #23
0
        public static System.String escape(System.String text, EncodingCharacters encChars)
        {
            //First, take all special characters and replace them with something that is garbled
            for(int i=0;i<SPECIAL_ENCODING_VALUES.Length;i++)
            {
                string specialValues = SPECIAL_ENCODING_VALUES[i];
                text = text.Replace(specialValues, EncodeSpecialCharacters(i.ToString()));
            }
            //Encode each escape character
                        System.Collections.Hashtable esc = getEscapeSequences(encChars);
            System.Text.StringBuilder result = new System.Text.StringBuilder();
            SupportClass.SetSupport keys = new SupportClass.HashSetSupport(esc.Keys);
            System.String escChar = System.Convert.ToString(encChars.EscapeCharacter);
            int position = 0;
            while (position < text.Length)
            {
                System.Collections.IEnumerator it = keys.GetEnumerator();
                bool isReplaced = false;
                while (it.MoveNext() && !isReplaced)
                {
                    System.String seq = (System.String) it.Current;
                    System.String val = (System.String) esc[seq];
                    if (text.Substring(position, 1).Equals(val))
                    {
                        result.Append(seq);
                        isReplaced = true;
                    }
                }
                if (!isReplaced)
                {
                    result.Append(text.Substring(position, 1));
                }
                position++;
            }

            //Replace each garbled entry with the correct special value
            for(int i=0;i<SPECIAL_ENCODING_VALUES.Length;i++)
            {
                string specialValues = SPECIAL_ENCODING_VALUES[i];
                result.Replace(EncodeSpecialCharacters(i.ToString()), specialValues);
            }
            return result.ToString();
        }
Beispiel #24
0
        /// <summary>
        /// Unescape the string
        /// </summary>
        /// <param name="text"></param>
        /// <param name="encChars"></param>
        /// <returns></returns>
        public static String unescape(String text, EncodingCharacters encChars)
        {
            // is there an escape character in the text at all?
            if (text.IndexOf(encChars.EscapeCharacter) == -1)
            {
                return(text);
            }

            StringBuilder result     = new StringBuilder();
            int           textLength = text.Length;
            Hashtable     esc        = getEscapeSequences(encChars);

            SupportClass.ISetSupport keys = new SupportClass.HashSetSupport(esc.Keys);
            String escChar  = Convert.ToString(encChars.EscapeCharacter);
            int    position = 0;

            while (position < textLength)
            {
                IEnumerator it         = keys.GetEnumerator();
                bool        isReplaced = false;
                while (it.MoveNext() && !isReplaced)
                {
                    String seq       = (String)it.Current;
                    String val       = (String)esc[seq];
                    int    seqLength = seq.Length;
                    if (position + seqLength <= textLength)
                    {
                        if (text.Substring(position, (position + seqLength) - (position)).Equals(seq))
                        {
                            result.Append(val);
                            isReplaced = true;
                            position   = position + seq.Length;
                        }
                    }
                }
                if (!isReplaced)
                {
                    result.Append(text.Substring(position, ((position + 1)) - (position)));
                    position++;
                }
            }
            return(result.ToString());
        }
Beispiel #25
0
        /// <summary>   Populates the given Segment object with data from the given XML Element. </summary>
        /// <summary>   for the given Segment, or if there is an error while setting individual field
        ///             values. </summary>
        ///
        /// <param name="segmentObject">    The segment object. </param>
        /// <param name="segmentElement">   Element describing the segment. </param>

        public virtual void Parse(ISegment segmentObject, System.Xml.XmlElement segmentElement)
        {
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            //        for (int i = 1; i <= segmentObject.NumFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }

            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element &&
                    !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int           fieldNum       = System.Int32.Parse(fieldNumString);
                        this.ParseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        log.Debug(
                            "Child of segment " + segmentObject.GetStructureName() + " doesn't look like a field: "
                            + elementName);
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, this.Factory);
            }
        }
Beispiel #26
0
        ///
        ///     <summary> * unify - make VString unique, retaining initial order </summary>
        ///
        public virtual void unify()
        {
            SupportClass.HashSetSupport <string> @set = new SupportClass.HashSetSupport <string>();
            int size = Count;

            for (int i = 0; i < size; i++)
            {
                string s = this.stringAt(i);
                if (@set.Contains(s))
                {
                    this.RemoveAt(i);
                    i--;
                    size--;
                }
                else
                {
                    @set.Add(s);
                }
            }
        }
Beispiel #27
0
        /// <summary>Closes the given connection & removes from hash - to be called when there are 0 references to it </summary>
        private void  close(NuGenConnection c)
        {
            c.close();

            //remove from "connections"
            System.Collections.IEnumerator keys = new SupportClass.HashSetSupport(connections.Keys).GetEnumerator();
            bool removed = false;

            while (keys.MoveNext() && !removed)
            {
                System.Object key = keys.Current;
                System.Object val = connections[key];
                if (val.GetHashCode() == c.GetHashCode())
                {
                    connections.Remove(key);
                    numRefs.Remove(key);
                    removed = true;
                }
            }
        }
Beispiel #28
0
        ///
        ///	 <summary> * unify - make VElement unique, retaining initial order </summary>
        ///
        public virtual void unify()
        {
            SupportClass.HashSetSupport @set = new SupportClass.HashSetSupport();
            int size = Count;

            for (int i = 0; i < size; i++)
            {
                KElement e = this.item(i);
                if (@set.Contains(e))
                {
                    this.RemoveAt(i);
                    i--;
                    size--;
                }
                else
                {
                    @set.Add(e);
                }
            }
        }
Beispiel #29
0
        /// <summary> Populates the given Segment object with data from the given XML Element.</summary>
        /// <throws>  HL7Exception if the XML Element does not have the correct name and structure. </throws>
        /// <summary>      for the given Segment, or if there is an error while setting individual field values.
        /// </summary>
        public virtual void Parse(ISegment segmentObject, XmlElement segmentElement, ParserOptions parserOptions)
        {
            parserOptions = parserOptions ?? DefaultParserOptions;

            var done = new SupportClass.HashSetSupport();

            // for (int i = 1; i <= segmentObject.NumFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }
            var all = segmentElement.ChildNodes;

            for (var i = 0; i < all.Count; i++)
            {
                var elementName = all.Item(i).Name;
                if (Convert.ToInt16(all.Item(i).NodeType) == (short)XmlNodeType.Element && !done.Contains(elementName))
                {
                    done.Add(elementName);

                    var index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        // properly formatted element
                        var fieldNumString = elementName.Substring(index + 1);
                        var fieldNum       = int.Parse(fieldNumString);
                        ParseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        Log.Debug("Child of segment " + segmentObject.GetStructureName() + " doesn't look like a field: " + elementName);
                    }
                }
            }

            // set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.FixOBX5(segmentObject, Factory, parserOptions);
            }
        }
Beispiel #30
0
        /// <summary> Populates the given Segment object with data from the given XML Element.</summary>
        /// <throws>  HL7Exception if the XML Element does not have the correct name and structure </throws>
        /// <summary>      for the given Segment, or if there is an error while setting individual field values.
        /// </summary>
        public virtual void  parse(Segment segmentObject, System.Xml.XmlElement segmentElement)
        {
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            //        for (int i = 1; i <= segmentObject.numFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }

            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element && !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int           fieldNum       = System.Int32.Parse(fieldNumString);
                        parseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        log.debug("Child of segment " + segmentObject.getStructureName() + " doesn't look like a field: " + elementName);
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, Factory);
            }
        }
Beispiel #31
0
        ///
        ///	 <summary> * get the list of QueueEntryDef/@QueueEntryIDs strings as a set
        ///	 *  </summary>
        ///	 * <returns> the set of QueueEntryIDs, null if no QueueEntryDef is specified </returns>
        ///
        public virtual SupportClass.SetSupport <string> getQueueEntryDefSet()
        {
            SupportClass.HashSetSupport <string> @set = null;

            VElement v = getChildElementVector(ElementName.QUEUEENTRYDEF, null);

            if (v != null)
            {
                int siz = v.Count;
                @set = siz == 0 ? null : new SupportClass.HashSetSupport <string>();
                for (int i = 0; i < siz; i++)
                {
                    string qeid = ((JDFQueueEntryDef)v[i]).getQueueEntryID();
                    if (!isWildCard(qeid))
                    {
                        @set.Add(qeid);
                    }
                }
            }

            return(@set != null && @set.Count > 0 ? @set : null);
        }
Beispiel #32
0
        public virtual void testAppendAnchor()
        {
            JDFDoc     doc = new JDFDoc("JDF");
            JDFElement e   = doc.getJDFRoot();

            SupportClass.HashSetSupport m = new SupportClass.HashSetSupport();
            KElement e2 = e.appendElement("e2");

            // Java to C# Conversion - Divide number of tests by 1000 for now
            for (int i = 0; i < 10; i++)
            {
                JDFElement appendElement = (JDFElement)e2.appendElement("FooBar");
                string     s             = appendElement.appendAnchor(null);
                if (m.Contains(s))
                {
                    Assert.Fail("oops");
                }
                Assert.AreEqual(s, appendElement.getID());
                Assert.IsTrue(s.IndexOf("..") < 0);
                m.Add(s);
            }
        }
        /// <summary> Returns a set of all vertices that are in the maximally connected
        /// component together with the specified vertex. For more on maximally
        /// connected component, see <a
        /// href="http://www.nist.gov/dads/HTML/maximallyConnectedComponent.html">
        /// http://www.nist.gov/dads/HTML/maximallyConnectedComponent.html</a>.
        ///
        /// </summary>
        /// <param name="vertex">the vertex for which the connected set to be returned.
        ///
        /// </param>
        /// <returns> a set of all vertices that are in the maximally connected
        /// component together with the specified vertex.
        /// </returns>
        public virtual SupportClass.SetSupport connectedSetOf(System.Object vertex)
        {
            SupportClass.SetSupport connectedSet = (SupportClass.SetSupport)m_vertexToConnectedSet[vertex];

            if (connectedSet == null)
            {
                //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
                connectedSet = new SupportClass.HashSetSupport();

                BreadthFirstIterator i = new BreadthFirstIterator(m_graph, vertex);

                //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 (i.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'"
                    connectedSet.Add(i.Current);
                }

                m_vertexToConnectedSet[vertex] = connectedSet;
            }

            return(connectedSet);
        }
Beispiel #34
0
        protected internal static PropertyValue[] ToPropertyValues(IDictionary properties)
        {
            PropertyValue[] propertyValues = new PropertyValue[properties.Count];
            int             i = 0;

            for (IEnumerator iter = new SupportClass.HashSetSupport(properties).GetEnumerator(); iter.MoveNext();)
            {
                if (iter.Current != null)
                {
                    DictionaryEntry entry        = (DictionaryEntry)iter.Current;
                    Object          valueRenamed = entry.Value;
                    var             renamed      = valueRenamed as IDictionary;
                    if (renamed != null)
                    {
                        // recursively Convert nested Map to PropertyValue[]
                        IDictionary subProperties = renamed;
                        valueRenamed = ToPropertyValues(subProperties);
                    }
                    propertyValues[i++] = Property((String)entry.Key, valueRenamed);
                }
            }
            return(propertyValues);
        }
Beispiel #35
0
		public MovieEncoder(TagHandler handler)
		{
			this.handler = handler;
			//UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
			done = new SupportClass.HashSetSupport();
		}
		/// <summary> Populates the given Segment object with data from the given XML Element.</summary>
		/// <throws>  HL7Exception if the XML Element does not have the correct name and structure </throws>
		/// <summary>      for the given Segment, or if there is an error while setting individual field values.
		/// </summary>
		public virtual void  parse(Segment segmentObject, System.Xml.XmlElement segmentElement)
		{
			SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();
			
			System.Xml.XmlNodeList all = segmentElement.ChildNodes;
			for (int i = 0; i < all.Count; i++)
			{
				System.String elementName = all.Item(i).Name;
				if (System.Convert.ToInt16(all.Item(i).NodeType) == (short) System.Xml.XmlNodeType.Element && !done.Contains(elementName))
				{
					done.Add(elementName);
					
					int index = elementName.IndexOf('.');
					if (index >= 0 && elementName.Length > index)
					{
						//properly formatted element
						System.String fieldNumString = elementName.Substring(index + 1);
						int fieldNum = System.Int32.Parse(fieldNumString);
						parseReps(segmentObject, segmentElement, elementName, fieldNum);
					}
					else
					{
					}
				}
			}
			
			//set data type of OBX-5        
			if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
			{
				Varies.fixOBX5(segmentObject, Factory);
			}
		}
Beispiel #37
0
		public override void  symbolClass(SymbolClass tag)
		{
			open(tag);
			end();
			
			//UPGRADE_TODO: Method 'java.util.Map.entrySet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilMapentrySet'"
			System.Collections.IEnumerator it = new SupportClass.HashSetSupport(tag.class2tag).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 (it.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'"
				System.Collections.DictionaryEntry e = (System.Collections.DictionaryEntry) it.Current;
				System.String className = (System.String) e.Key;
				DefineTag ref_Renamed = (DefineTag) e.Value;
				indent();
				//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
				out_Renamed.WriteLine("<Symbol idref='" + dict.getId(ref_Renamed) + "' className='" + className + "' />");
			}
			
			if (tag.topLevelClass != null)
			{
				indent();
				//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
				out_Renamed.WriteLine("<Symbol idref='0' className='" + tag.topLevelClass + "' />");
			}
			
			
			close(tag);
		}
Beispiel #38
0
 /// <summary> Construct a JSONObject from a Map.
 /// 
 /// </summary>
 /// <param name="map">A map object that can be used to initialize the contents of
 /// the JSONObject.
 /// </param>
 /// <throws>  JSONException  </throws>
 public JSONObject(System.Collections.IDictionary map)
 {
     this.map = new System.Collections.Hashtable();
     if (map != null)
     {
         System.Collections.IEnumerator i = new SupportClass.HashSetSupport(map).GetEnumerator();
         while (i.MoveNext())
         {
             System.Collections.DictionaryEntry e = (System.Collections.DictionaryEntry)i.Current;
             this.map[e.Key] = wrap(e.Value);
         }
     }
 }
		private static void  setGroupSuccessors(System.Collections.IDictionary theSuccessors, System.String theSegName)
		{
			for (System.Collections.IEnumerator it = new SupportClass.HashSetSupport(theSuccessors.Keys).GetEnumerator(); it.MoveNext(); )
			{
				StructRef from = (StructRef) it.Current;
				StructRef to = (StructRef) theSuccessors[from];
				from.setSuccessor(theSegName, to);
			}
			theSuccessors.Clear();
		}
Beispiel #40
0
        /// <summary> Populates the given Segment object with data from the given XML Element.</summary>
        /// <throws>  HL7Exception if the XML Element does not have the correct name and structure </throws>
        /// <summary>      for the given Segment, or if there is an error while setting individual field values.
        /// </summary>
        public virtual void parse(Segment segmentObject, System.Xml.XmlElement segmentElement)
        {
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            //        for (int i = 1; i <= segmentObject.numFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }

            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short) System.Xml.XmlNodeType.Element && !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int fieldNum = System.Int32.Parse(fieldNumString);
                        parseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        log.debug("Child of segment " + segmentObject.getStructureName() + " doesn't look like a field: " + elementName);
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, Factory);
            }
        }
Beispiel #41
0
        /// <summary>
        /// Unescape the string
        /// </summary>
        /// <param name="text"></param>
        /// <param name="encChars"></param>
        /// <returns></returns>
        public static String unescape(String text, EncodingCharacters encChars)
        {
            // is there an escape character in the text at all?
            if (text.IndexOf(encChars.EscapeCharacter) == -1)
            {
                return text;
            }

            StringBuilder result = new StringBuilder();
            int textLength = text.Length;
            Hashtable esc = getEscapeSequences(encChars);
            SupportClass.ISetSupport keys = new SupportClass.HashSetSupport(esc.Keys);
            String escChar = Convert.ToString(encChars.EscapeCharacter);
            int position = 0;
            while (position < textLength)
            {
                IEnumerator it = keys.GetEnumerator();
                bool isReplaced = false;
                while (it.MoveNext() && !isReplaced)
                {
                    String seq = (String) it.Current;
                    String val = (String) esc[seq];
                    int seqLength = seq.Length;
                    if (position + seqLength <= textLength)
                    {
                        if (text.Substring(position, (position + seqLength) - (position)).Equals(seq))
                        {
                            result.Append(val);
                            isReplaced = true;
                            position = position + seq.Length;
                        }
                    }
                }
                if (!isReplaced)
                {
                    result.Append(text.Substring(position, ((position + 1)) - (position)));
                    position++;
                }
            }
            return result.ToString();
        }
		/// <summary>Closes the given connection & removes from hash - to be called when there are 0 references to it </summary>
		private void  close(NuGenConnection c)
		{
			c.close();
			
			//remove from "connections"  
			System.Collections.IEnumerator keys = new SupportClass.HashSetSupport(connections.Keys).GetEnumerator();
			bool removed = false;
			while (keys.MoveNext() && !removed)
			{
				System.Object key = keys.Current;
				System.Object val = connections[key];
				if (val.GetHashCode() == c.GetHashCode())
				{
					connections.Remove(key);
					numRefs.Remove(key);
					removed = true;
				}
			}
		}
		public override void  symbolClass(SymbolClass tag)
		{
			tagw.writeUI16(tag.class2tag.Count + (tag.topLevelClass != null?1:0));
			//UPGRADE_TODO: Method 'java.util.Map.entrySet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilMapentrySet'"
			System.Collections.IEnumerator it = new SupportClass.HashSetSupport(tag.class2tag).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 (it.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'"
				System.Collections.DictionaryEntry e = (System.Collections.DictionaryEntry) it.Current;
				System.String name = (System.String) e.Key;
				DefineTag ref_Renamed = (DefineTag) e.Value;
				
				int idref = dict.getId(ref_Renamed);
				tagw.writeUI16(idref);
				tagw.writeString(name);
			}
			if (tag.topLevelClass != null)
			{
				tagw.writeUI16(0);
				tagw.writeString(tag.topLevelClass);
			}
			encodeTag(tag);
		}
Beispiel #44
0
		internal virtual StreamWriter traceFile()
		{
			if (m_trace == null)
			{
				m_trace = new StreamWriter("mm_debug_api_trace.txt", false, System.Text.Encoding.Default); //$NON-NLS-1$
				try
				{
					m_trace.Write(DateTime.Now.ToString("r"));
				}
				catch (Exception)
				{
					m_trace.Write("Date unknown");
				} //$NON-NLS-1$
				try
				{
					m_trace.Write(s_newline);
					
					// java properties dump
					System.Collections.Specialized.NameValueCollection props = SystemProperties.getProperties();

                    foreach (String value in props)
                    {
                        m_trace.WriteLine(value);
                    }
					
					m_trace.Write(s_newline);
					
					// property dump
					System.Collections.IEnumerator keys = new SupportClass.HashSetSupport(m_prefs.Keys).GetEnumerator();
					while (keys.MoveNext())
					{
						Object key = keys.Current;
						Object value = m_prefs[key];
						m_trace.Write(key.ToString());
						m_trace.Write(" = "); //$NON-NLS-1$
						m_trace.Write(value.ToString());
						m_trace.Write(s_newline);
					}
				}
				catch (Exception e)
				{
                    if (Trace.error)
                    {
                        Console.Error.Write(e.StackTrace);
                        Console.Error.Flush();
                    }
				}
				m_trace.Write(s_newline);
			}
			return m_trace;
		}
Beispiel #45
0
		/// <summary> Checks whether the specified Macintosh web browser is currently
		/// running.  You should only call this function if you have already
		/// checked that you are running on a Mac.
		/// 
		/// </summary>
		/// <param name="browserName">a name, e.g. "Safari", "Firefox", "Camino"
		/// </param>
		/// <returns> true if currently running
		/// </returns>
		private SupportClass.SetSupport runningApplications()
		{
			String running = executeAppleScript(new String[]{"tell application \"System Events\"", "	name of processes", "end tell"}, null);
			String[] apps = running.split(", "); //$NON-NLS-1$
			//UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
			SupportClass.SetSupport retval = new SupportClass.HashSetSupport();
			for (int i = 0; i < apps.Length; ++i)
				retval.Add(apps[i]);
			return retval;
		}
Beispiel #46
0
		/// <summary> Finds a greedy approximation for a minimal vertex cover of a specified
		/// graph. At each iteration, the algorithm picks the vertex with the
		/// highest degree and adds it to the cover, until all edges are covered.
		/// 
		/// <p>
		/// The algorithm works on undirected graphs, but can also work on directed
		/// graphs when their edge-directions are ignored. To ignore edge
		/// directions you can use {@link
		/// org._3pq.jgrapht.GraphHelper#undirectedGraph(Graph)} or {@link
		/// org._3pq.jgrapht.graph.AsUndirectedGraph}.
		/// </p>
		/// 
		/// </summary>
		/// <param name="g">the graph for which vertex cover approximation is to be found.
		/// 
		/// </param>
		/// <returns> a set of vertices which is a vertex cover for the specified
		/// graph.
		/// </returns>
		public virtual SupportClass.SetSupport findGreedyCover(UndirectedGraph g)
		{
			// C <-- {}
			//UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
			SupportClass.SetSupport cover = new SupportClass.HashSetSupport();
			
			// G' <-- G
			UndirectedGraph sg = new UndirectedSubgraph(g, null, null);
			
			// compare vertices in descending order of degree
			VertexDegreeComparator comp = new VertexDegreeComparator(sg);
			
			// while G' != {}
			while (sg.edgeSet().Count > 0)
			{
				// v <-- vertex with maximum degree in G'
				System.Object v = SupportClass.CollectionsSupport.Max(sg.vertexSet(), comp);
				
				// C <-- C U {v}
				cover.Add(v);
				
				// remove from G' every edge incident on v, and v itself
				sg.removeVertex(v);
			}
			
			return cover;
		}
Beispiel #47
0
		/// <summary> Finds a 2-approximation for a minimal vertex cover of the specified
		/// graph. The algorithm promises a cover that is at most double the size
		/// of a minimal cover. The algorithm takes O(|E|) time.
		/// 
		/// <p>
		/// For more details see Jenny Walter, CMPU-240: Lecture notes for Language
		/// Theory and Computation, Fall 2002, Vassar College, <a
		/// href="http://www.cs.vassar.edu/~walter/cs241index/lectures/PDF/approx.pdf">
		/// 
		/// http://www.cs.vassar.edu/~walter/cs241index/lectures/PDF/approx.pdf</a>.
		/// </p>
		/// 
		/// </summary>
		/// <param name="g">the graph for which vertex cover approximation is to be found.
		/// 
		/// </param>
		/// <returns> a set of vertices which is a vertex cover for the specified
		/// graph.
		/// </returns>
		public virtual SupportClass.SetSupport find2ApproximationCover(Graph g)
		{
			// C <-- {}
			//UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
			SupportClass.SetSupport cover = new SupportClass.HashSetSupport();
			
			// G'=(V',E') <-- G(V,E)
			Subgraph sg = new Subgraph(g, null, null);
			
			// while E' is non-empty
			while (sg.edgeSet().Count > 0)
			{
				// let (u,v) be an arbitrary edge of E'
				//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'"
				Edge e = (Edge) sg.edgeSet().GetEnumerator().Current;
				
				// C <-- C U {u,v}
				System.Object u = e.Source;
				System.Object v = e.Target;
				cover.Add(u);
				cover.Add(v);
				
				// remove from E' every edge incident on either u or v
				sg.removeVertex(u);
				sg.removeVertex(v);
			}
			
			return cover; // return C
		}