/// <summary>
        ///
        /// </summary>
        /// <param name="searchEnv"></param>
        /// <param name="start0"></param>
        /// <param name="end0"></param>
        /// <param name="mcs"></param>
        private void ComputeSelect(Envelope searchEnv, int start0, int end0, MonotoneChainSelectAction mcs)
        {
            var p0 = _pts[start0];
            var p1 = _pts[end0];

            // terminating condition for the recursion
            if (end0 - start0 == 1)
            {
                mcs.Select(this, start0);
                return;
            }
            // nothing to do if the envelopes don't overlap
            if (!searchEnv.Intersects(p0, p1))
            {
                return;
            }

            // the chains overlap, so split each in half and iterate  (binary search)
            int mid = (start0 + end0) / 2;

            // Assert: mid != start or end (since we checked above for end - start <= 1)
            // check terminating conditions before recursing
            if (start0 < mid)
            {
                ComputeSelect(searchEnv, start0, mid, mcs);
            }
            if (mid < end0)
            {
                ComputeSelect(searchEnv, mid, end0, mcs);
            }
        }
 /// <summary>
 /// Determine all the line segments in the chain whose envelopes overlap
 /// the searchEnvelope, and process them.
 /// </summary>
 /// <remarks>
 /// The monotone chain search algorithm attempts to optimize
 /// performance by not calling the select action on chain segments
 /// which it can determine are not in the search envelope.
 /// However, it *may* call the select action on segments
 /// which do not intersect the search envelope.
 /// This saves on the overhead of checking envelope intersection
 /// each time, since clients may be able to do this more efficiently.
 /// </remarks>
 /// <param name="searchEnv">The search envelope</param>
 /// <param name="mcs">The select action to execute on selected segments</param>
 public void Select(Envelope searchEnv, MonotoneChainSelectAction mcs)
 {
     ComputeSelect(searchEnv, _start, _end, mcs);
 }