src/smt/theory_jobscheduler.cpp
/**
     * find idx, if any, such that t is within the time interval of available[idx]
     */
find idx, if any, such that t is within the time interval of available[idx]
find idx if any such that t is within the time interval of available [ idx ]
bool theory_jobscheduler::resource_available(unsigned r, time_t t, unsigned& idx) {
        vector<res_available>& available = m_resources[r].m_available;
        unsigned lo = 0, hi = available.size(), mid = hi / 2;
        while (lo < hi) {
            SASSERT(lo <= mid && mid < hi);
            res_available const& ra = available[mid];
            if (ra.m_start <= t && t <= ra.m_end) {
                idx = mid;
                return true;
            }
            else if (ra.m_start > t && mid > 0) {
                hi = mid;
                mid = lo + (mid - lo) / 2;
            }
            else if (ra.m_end < t) {
                lo = mid + 1;
                mid += (hi - mid) / 2;
            }
            else {
                break;
            }
        }
        return false;
    }
bool theory_jobscheduler :: resource_available ( unsigned r , time_t t , unsigned & idx ) { vector < res_available > & available = m_resources [ r ] . m_available ; unsigned lo = 0 , hi = available . size ( ) , mid = hi / 2 ; while ( lo < hi ) { SASSERT ( lo <= mid && mid < hi ) ; res_available const & ra = available [ mid ] ; if ( ra . m_start <= t && t <= ra . m_end ) { idx = mid ; return true ; } else if ( ra . m_start > t && mid > 0 ) { hi = mid ; mid = lo + ( mid - lo ) / 2 ; } else if ( ra . m_end < t ) { lo = mid + 1 ; mid += ( hi - mid ) / 2 ; } else { break ; } } return false ; }
find idx, if any, such that t is within the time interval of available[idx]
find idx if any such that t is within the time interval of available [ idx ]