+// add item assuming the array is sorted with fnCompare function
+void wxBaseArray::Add(long lItem, CMPFUNC fnCompare)
+{
+ size_t i,
+ lo = 0,
+ hi = m_uiCount;
+ int res;
+
+ while ( lo < hi ) {
+ i = (lo + hi)/2;
+
+ res = (*fnCompare)((const void *)lItem, (const void *)m_pItems[i]);
+ if ( res < 0 )
+ hi = i;
+ else if ( res > 0 )
+ lo = i + 1;
+ else {
+ lo = hi = i;
+ break;
+ }
+ }
+
+ wxASSERT( lo == hi ); // I hope I got binary search right :-)
+
+ Insert(lItem, lo);
+}
+