Function: breadcrumb--bisect
breadcrumb--bisect is a natively compiled function defined in
breadcrumb.el.
Signature
(breadcrumb--bisect A X &key (FROM 0) (TO (length a)) KEY FROM-END)
Documentation
Compute index to insert X in sequence A, keeping it sorted.
If X already in A, the resulting index is the leftmost such index, unless FROM-END is t. KEY is as usual in other CL land.
Source Code
;; Defined in /nix/store/3gd3jzhj3g7mbwy1i3w6ci5d2md9d8r2-emacs-packages-deps/share/emacs/site-lisp/elpa/breadcrumb-1.0.1/breadcrumb.el
;;;; "ipath" management logic and imenu interoperation
;;
(cl-defun bc--bisect (a x &key (from 0) (to (length a)) key from-end)
"Compute index to insert X in sequence A, keeping it sorted.
If X already in A, the resulting index is the leftmost such
index, unless FROM-END is t. KEY is as usual in other CL land."
(cl-macrolet ((search (from-end key)
`(cl-loop while (< from to)
for mid = (/ (+ from to) 2)
for p1 = (elt a mid)
for p2 = ,(if key `(funcall key p1) `p1)
if (,(if from-end '< '<=) x p2)
do (setq to mid) else do (setq from (1+ mid))
finally return from)))
(if from-end (if key (search t key) (search t nil))
(if key (search nil key) (search nil nil)))))