internal void SortNewNodeSet(Processor proc, ArrayList sortarray) { Debug.Assert(0 < sortarray.Count); int numSorts = sortarray.Count; XPathSortComparer comparer = new XPathSortComparer(numSorts); for (int i = 0; i < numSorts; i++) { Sort sort = (Sort)sortarray[i] !; Query expr = proc.GetCompiledQuery(sort.select); comparer.AddSort(expr, new XPathComparerHelper(sort.order, sort.caseOrder, sort.lang, sort.dataType)); } List <SortKey> results = new List <SortKey>(); Debug.Assert(proc.ActionStack.Peek() == this, "the trick we are doing with proc.Current will work only if this is topmost frame"); while (NewNextNode(proc)) { XPathNodeIterator?savedNodeset = _nodeSet; _nodeSet = _newNodeSet; // trick proc.Current node SortKey key = new SortKey(numSorts, /*originalPosition:*/ results.Count, _newNodeSet !.Current !.Clone()); for (int j = 0; j < numSorts; j++) { key[j] = comparer.Expression(j).Evaluate(_newNodeSet); } results.Add(key); _nodeSet = savedNodeset; // restore proc.Current node } results.Sort(comparer); _newNodeSet = new XPathSortArrayIterator(results); }
internal void SortNewNodeSet(Processor proc, ArrayList sortarray) { Debug.Assert(0 < sortarray.Count); int numSorts = sortarray.Count; XPathSortComparer comparer = new XPathSortComparer(numSorts); IQuery[] sortExpressions = new IQuery[numSorts]; ArrayList comparers = new ArrayList(numSorts); for (int i = 0; i < numSorts; i++) { Sort sort = (Sort)sortarray[i]; XPathExpression expr = proc.GetCompiledQuery(sort.select); comparer.AddSort( ((CompiledXpathExpr)expr).QueryTree, new XPathComparerHelper(sort.order, sort.caseOrder, sort.lang, sort.dataType) ); } ArrayList results = new ArrayList(); Debug.Assert(proc.ActionStack.Peek() == this, "the trick we are doing with proc.Current will work only if this is topmost frame"); while (NewNextNode(proc)) { XPathNodeIterator savedNodeset = this.nodeSet; this.nodeSet = this.newNodeSet; // trick proc.Current node SortKey key = new SortKey(numSorts, /*originalPosition:*/ results.Count, this.newNodeSet.Current.Clone()); for (int j = 0; j < numSorts; j++) { key[j] = comparer.Expression(j).getValue(this.newNodeSet.Current, this.newNodeSet); } results.Add(key); this.nodeSet = savedNodeset; // restore proc.Current node } results.Sort(comparer); this.newNodeSet = new XPathSortArrayIterator(results); }
internal void SortNewNodeSet(Processor proc, ArrayList sortarray) { Debug.Assert(0 < sortarray.Count); int numSorts = sortarray.Count; XPathSortComparer comparer = new XPathSortComparer(numSorts); for (int i = 0; i < numSorts; i++) { Sort sort = (Sort) sortarray[i]; Query expr = proc.GetCompiledQuery(sort.select); comparer.AddSort(expr, new XPathComparerHelper(sort.order, sort.caseOrder, sort.lang, sort.dataType)); } List<SortKey> results = new List<SortKey>(); Debug.Assert(proc.ActionStack.Peek() == this, "the trick we are doing with proc.Current will work only if this is topmost frame"); while (NewNextNode(proc)) { XPathNodeIterator savedNodeset = this.nodeSet; this.nodeSet = this.newNodeSet; // trick proc.Current node SortKey key = new SortKey(numSorts, /*originalPosition:*/results.Count, this.newNodeSet.Current.Clone()); for (int j = 0; j < numSorts; j ++) { key[j] = comparer.Expression(j).Evaluate(this.newNodeSet); } results.Add(key); this.nodeSet = savedNodeset; // restore proc.Current node } results.Sort(comparer); this.newNodeSet = new XPathSortArrayIterator(results); }