MCPcopy Create free account
hub / github.com/davisking/dlib / binary_search

Method binary_search

dlib/static_map/static_map_kernel_1.h:590–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588 typename compare
589 >
590 bool static_map_kernel_1<domain,range,compare>::
591 binary_search (
592 const domain& item,
593 unsigned long& pos
594 ) const
595 {
596 unsigned long high = map_size;
597 unsigned long low = 0;
598 unsigned long p = map_size;
599 unsigned long idx;
600 while (p > 0)
601 {
602 p = (high-low)>>1;
603 idx = p+low;
604 if (comp(item , d[idx]))
605 {
606 high = idx;
607 }
608 else if (comp(d[idx] , item))
609 {
610 low = idx;
611 }
612 else
613 {
614 pos = idx;
615 return true;
616 }
617 }
618 return false;
619 }
620
621// ----------------------------------------------------------------------------------------
622

Callers

nothing calls this directly

Calls 1

compFunction · 0.85

Tested by

no test coverage detected