public Int32 Compare(SortKey x, SortKey y) { #if DEBUG System.Diagnostics.Debug.WriteLine("Comparing >>>>"); x.Dump(); y.Dump(); #endif int result = 0; for (Int32 i = 0; i < x.NumKeyParts; i++) { result = ((IComparer)_comparers[i]).Compare(x[i], y[i]); if (result != 0) { break; } } #if DEBUG System.Diagnostics.Debug.WriteLine("result = " + result.ToString()); System.Diagnostics.Debug.WriteLine(""); #endif // if after all comparisions, the two sort keys are still equal, // preserve the doc order return((result == 0) ? -1 : result); }
public int Compare(SortKey x, SortKey y) { int result = 0; for (int i = 0; i < x.NumKeys; i++) { result = this.comparers[i].Compare(x[i], y[i]); if (result != 0) { return(result); } } Debug.Assert(result == 0); // if after all comparisions, the two sort keys are still equal, // preserve the doc order return(x.OriginalPosition - y.OriginalPosition); }
private void BuildResultsList() { Int32 numSorts = this.comparer.NumSorts; Debug.Assert(numSorts > 0, "Why was the sort query created?"); XPathNavigator eNext; while ((eNext = _qyInput.advance()) != null) { SortKey key = new SortKey(numSorts, /*originalPosition:*/ this.results.Count, eNext.Clone()); for (Int32 j = 0; j < numSorts; j++) { object keyval = this.comparer.Expression(j).getValue(_qyInput); key[j] = keyval; } results.Add(key); } results.Sort(this.comparer); }
private void BuildResultsList() { XPathNavigator eNext; SortKey key; Int32 numSorts = _sortExpressions.Count; System.Diagnostics.Debug.Assert(numSorts > 0, "Why was the sort query created?"); while (true) { eNext = _qyInput.advance(); if (eNext == null) { break; } // if this is the first time i.e., the cache is empty // and if we an xslt context to work with /* if (_ResultCount == 0 && _context != null) * for (Int32 i=0; i<numSorts; i++) * ((IQuery)_sortExpressions[i]).SetXsltContext(_context);*/ // create the special object that represent the composite key // This key object will act as a container for the primary key value, // secondary key value etc. key = new SortKey(numSorts); for (Int32 j = 0; j < numSorts; j++) { object keyval = ((IQuery)_sortExpressions[j]).getValue(_qyInput); key.SetKeyValue(keyval, j); } _Results.Add(key, eNext.Clone()); _ResultCount++; } }