GetCompiledQuery() private method

private GetCompiledQuery ( int key ) : Query
key int
return Query
Beispiel #1
0
        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);
            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);
        }