public int BinarySearchPoints(Point pt, BinarySearchParameter parameter)
        {
            int    start = 0;
            int    end   = data.Count - 1;
            double tol   = parameter.GetTolerance();

            while (start <= end)
            {
                int mid = end + (start - end) / 2;

                if (pt.Match(data[mid], tol))
                {
                    return(mid);
                }
                else if (pt.CompareTo(data[mid]) < 0)
                {
                    end = mid - 1;
                }
                else
                {
                    start = mid + 1;
                }
            }

            return(-1);
        }
        public List <Point> ExtendAllMatch(Point pt, int matchIndx, BinarySearchParameter parameter)
        {
            List <Point> searched = new List <Point>();

            if (matchIndx < 0)
            {
                return(searched);
            }

            searched.Add(data[matchIndx]);

            int    left  = matchIndx - 1;
            int    right = matchIndx + 1;
            double tol   = parameter.GetTolerance();

            while (left >= 0)
            {
                if (pt.Match(data[left], tol))
                {
                    searched.Add(data[left]);
                    left--;
                }
                else
                {
                    break;
                }
            }


            while (right < data.Count)
            {
                if (pt.Match(data[right], tol))
                {
                    searched.Add(data[right]);
                    right++;
                }
                else
                {
                    break;
                }
            }
            return(searched);
        }
 public List <Point> GetSearchResult(Point pt, BinarySearchParameter parameter)
 {
     return(ExtendAllMatch(pt, BinarySearchPoints(pt, parameter), parameter));
 }