Function: treemacs--binary-index-search

treemacs--binary-index-search is a byte-compiled function defined in treemacs-tag-follow-mode.el.

Signature

(treemacs--binary-index-search POINT LIST &optional (START 0) (END (1- (length list))))

Documentation

Find the position of POINT in LIST using a binary search.

Continuation of treemacs--find-index-pos. Search LIST between START & END.

POINT: Integer LIST: Sorted Tag Path List START: Integer END: Integer

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-tag-follow-mode.el
(cl-defun treemacs--binary-index-search (point list &optional (start 0) (end (1- (length list))))
  "Find the position of POINT in LIST using a binary search.
Continuation of `treemacs--find-index-pos'.  Search LIST between START & END.

POINT: Integer
LIST: Sorted Tag Path List
START: Integer
END: Integer"
  (declare (pure t) (side-effect-free t))
  (let* ((index  (+ start (/ (- end start) 2)))
         (elem1  (nth index list))
         (elem2  (nth (1+ index) list))
         (pos1   (-> elem1 car cdr))
         (pos2   (-> elem2 car cdr)))
    (cond
     ((and (> point pos1)
           (<= point pos2))
      elem1)
     ((> pos2 point)
      (treemacs--binary-index-search point list 0 index))
     ((< pos2 point)
      (treemacs--binary-index-search point list index end)))))