template<typename type, class allocator>
Performs a binary search to find an item (needs a numerically sorted array), returning -1 if not found.
Definition at line 201 of file qmemarray.h. 00202 { // God damn std::binary_search doesn't return the position :( 00203 int lbound=0, ubound=(int)size()-1, c; 00204 while(lbound<=ubound) 00205 { 00206 c=(lbound+ubound)/2; 00207 const type &cval=at(c); 00208 if(val==cval) 00209 return c; 00210 else if(val<cval) 00211 ubound=c-1; 00212 else 00213 lbound=c+1; 00214 } 00215 return -1; 00216 }
|