Exemplo n.º 1
0
//		public static org.eclipse.wst.xml.xpath2.processor.ResultSequence eliminate_dups(org.eclipse.wst.xml.xpath2.processor.ResultSequence rs)
//		{
//			Hashtable added = new Hashtable(rs.size());


//			for (IEnumerator i = rs.GetEnumerator(); i.MoveNext();)
//			{
//				NodeType node = (NodeType) i.Current;
//				Node n = node.node_value();

//				if (added.ContainsKey(n))
//				{
////JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only:
//					i.remove();
//				}
//				else
//				{
//					added[n] = true;
//				}
//			}
//			return rs;
//		}

        public static org.eclipse.wst.xml.xpath2.processor.ResultSequence sort_document_order(org.eclipse.wst.xml.xpath2.processor.ResultSequence rs)
        {
            ArrayList res = new ArrayList(rs.size());

            for (IEnumerator i = rs.GetEnumerator(); i.MoveNext();)
            {
                NodeType node  = (NodeType)i.Current;
                bool     added = false;

                for (int j = 0; j < res.Count; j++)
                {
                    NodeType x = (NodeType)res[j];

                    if (before(node, x))
                    {
                        res.Insert(j, node);
                        added = true;
                        break;
                    }
                }
                if (!added)
                {
                    res.Add(node);
                }
            }

            rs = ResultSequenceFactory.create_new();
            for (IEnumerator i = res.GetEnumerator(); i.MoveNext();)
            {
                NodeType node = (NodeType)i.Current;

                rs.add(node);
            }

            return(rs);
        }