/// <summary>
        /// Searches for the specified object and returns the zero-based virtual index of the first occurrence in a linear list that starts at the specified index and contains the specified number of elements.
        /// </summary>
        /// <param name="item">The object to locate in the <see cref="Partition{T}"/>. The value can be null for reference types.</param>
        /// <param name="startIndex">The zero-based starting index of the search. 0 (zero) is valid in an empty partition.</param>
        /// <param name="count">The number of elements in the section to search.</param>
        /// <returns>
        /// The zero-based virtual index of the first occurrence of <paramref name="item"/> within the range of elements in a linear list that starts at <paramref name="startIndex"/> and contains <paramref name="count"/> number of elements, if found; otherwise, –1.
        /// </returns>
        public long IndexOf(T item, long startIndex, long count)
        {
            Debug.Assert(startIndex >= 0 && startIndex <= Count);
            Debug.Assert(count >= 0);
            Debug.Assert(startIndex + count <= Count);

            long Result = -1;

            int SegmentIndex;
            int ElementStartIndex;
            int CacheIndex;

            GetPosition(startIndex, out SegmentIndex, out ElementStartIndex, out CacheIndex);

            long ItemIndex      = startIndex - ElementStartIndex;
            long RemainingCount = count;

            while (SegmentIndex < SegmentTable.Count && RemainingCount > 0)
            {
                ISegment <T> Segment = SegmentTable[SegmentIndex];
                if (Segment.Count == 0)
                {
                    break;
                }

                int CompareCount = (Segment.Count - ElementStartIndex <= RemainingCount) ? Segment.Count - ElementStartIndex : (int)RemainingCount;
                int ElementIndex = Segment.IndexOf(item, ElementStartIndex, CompareCount);
                if (ElementIndex >= 0)
                {
                    Result = ItemIndex + ElementIndex;
                    break;
                }

                ElementStartIndex = 0;
                RemainingCount   -= CompareCount;
                ItemIndex        += Segment.Count;
                SegmentIndex++;
            }

            Debug.Assert(RemainingCount >= 0);
            Debug.Assert(Result == -1 || (Result >= startIndex && Result < startIndex + count && IsItemEqual(Result, item)));

#if DEBUG
            AssertInvariant();
#endif

            return(Result);
        }