Update of /cvsroot/mahogany/M/src/adb
In directory sc8-pr-cvs1:/tmp/cvs-serv32004
Modified Files:
ProvLine.cpp
Log Message:
wxWindows 2.4 has broken search in sorted array
Index: ProvLine.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/adb/ProvLine.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -2 -r1.2 -r1.3
--- ProvLine.cpp 30 Aug 2003 10:50:54 -0000 1.2
+++ ProvLine.cpp 4 Sep 2003 13:03:40 -0000 1.3
@@ -378,5 +378,30 @@
LineEntry *key = new LineEntry(NULL,name);
+#if wxCHECK_VERSION(2,5,0) // Bug in wxWindows 2.4 version of Index()
int index = m_entries.Index(key);
+#else
+ int low = 0; // Key is at position greater or equal to "low"
+ int high = m_entries.GetCount(); // Key is below "high"
+ while ( low < high - 1 ) // There are items to compare
+ {
+ int middle = (low + high) / 2; // Candidate key match
+ int compare = LineEntryCompare(key,m_entries.Item(middle));
+ if ( compare < 0 ) // Key is below "middle"
+ high = middle; // "high" changes
+ else if ( compare > 0 ) // Key is above "middle"
+ low = middle + 1; // "low" changes
+ else // Key is at "middle", we can set "low" and "high" exactly
+ {
+ low = middle;
+ high = middle + 1;
+ }
+ }
+
+ int index;
+ if ( low < high && LineEntryCompare(key,m_entries.Item(low)) == 0 )
+ index = low;
+ else
+ index = wxNOT_FOUND;
+#endif
key->DecRef();
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates