public override TermEnum Terms(Term term)
            {
                if (DEBUG)
                {
                    System.Diagnostics.Debug.WriteLine("MemoryIndexReader.terms: " + term);
                }

                int i; // index into info.sortedTerms
                int j; // index into sortedFields

                _index.SortFields();
                if (_index.sortedFields.Length == 1 && _index.sortedFields[0].Key == term.Field)
                {
                    j = 0; // fast path
                }
                else
                {
                    j = Array.BinarySearch(_index.sortedFields, new KeyValuePair <string, Info>(term.Field, null), Info.InfoComparer);
                }

                if (j < 0)
                {
                    // not found; choose successor
                    j = -j - 1;
                    i = 0;
                    if (j < _index.sortedFields.Length)
                    {
                        GetInfo(j).SortTerms();
                    }
                }
                else
                {
                    // found
                    Info info = GetInfo(j);
                    info.SortTerms();
                    i = Array.BinarySearch(info.SortedTerms, new KeyValuePair <string, ArrayIntList>(term.Text, null), Info.ArrayIntListComparer);
                    if (i < 0)
                    {
                        // not found; choose successor
                        i = -i - 1;
                        if (i >= info.SortedTerms.Length)
                        {
                            // move to next successor
                            j++;
                            i = 0;
                            if (j < _index.sortedFields.Length)
                            {
                                GetInfo(j).SortTerms();
                            }
                        }
                    }
                }
                int ix = i;
                int jx = j;

                return(new MemoryTermEnum(_index, this, ix, jx));
            }