public override bool LessThan(SubIterator <C> a, SubIterator <C> b) { int cmp = a.Current.CompareTo(b.Current); if (cmp != 0) { return(cmp < 0); } else { return(a.Index < b.Index); } }
public MergedIterator(bool removeDuplicates, params IEnumerator <T>[] iterators) { this.removeDuplicates = removeDuplicates; queue = new TermMergeQueue <T>(iterators.Length); top = new SubIterator <T> [iterators.Length]; int index = 0; foreach (IEnumerator <T> iter in iterators) { // If hasNext if (iter.MoveNext()) { SubIterator <T> sub = new SubIterator <T>(); sub.Current = iter.Current; sub.Iterator = iter; sub.Index = index++; queue.Add(sub); } } }
protected internal override bool LessThan(SubIterator <C> a, SubIterator <C> b) { int cmp; // LUCNENENET specific: For strings, we need to ensure we compare them ordinal if (typeof(C).Equals(typeof(string))) { cmp = (a.Current as string).CompareToOrdinal(b.Current as string); } else { cmp = a.Current.CompareTo(b.Current); } if (cmp != 0) { return(cmp < 0); } else { return(a.Index < b.Index); } }