[sword-svn] r1908 - in trunk: include src/keys
scribe at crosswire.org
scribe at crosswire.org
Mon Apr 24 23:01:32 MST 2006
Author: scribe
Date: 2006-04-24 23:01:30 -0700 (Mon, 24 Apr 2006)
New Revision: 1908
Modified:
trunk/include/listkey.h
trunk/src/keys/listkey.cpp
Log:
Added sort option
Modified: trunk/include/listkey.h
===================================================================
--- trunk/include/listkey.h 2006-04-25 06:00:55 UTC (rev 1907)
+++ trunk/include/listkey.h 2006-04-25 06:01:30 UTC (rev 1908)
@@ -118,6 +118,7 @@
virtual long Index(long index) { SetToElement (index); return Index (); }
virtual const char *getText() const;
virtual void setText(const char *ikey);
+ virtual void sort();
SWKEY_OPERATORS
ListKey & operator =(const ListKey &key) { copyFrom(key); return *this; }
Modified: trunk/src/keys/listkey.cpp
===================================================================
--- trunk/src/keys/listkey.cpp 2006-04-25 06:00:55 UTC (rev 1907)
+++ trunk/src/keys/listkey.cpp 2006-04-25 06:01:30 UTC (rev 1908)
@@ -316,5 +316,18 @@
SWKey::setText(ikey);
}
+// This sort impl sucks. Let's change it to a quicksort or some other efficient algol
+void ListKey::sort() {
+ for (int i = 0; i < arraycnt; i++) {
+ for (int j = i; j < arraycnt; j++) {
+ if (*array[j] < *array[i]) {
+ SWKey *tmp = array[i];
+ array[i] = array[j];
+ array[j] = tmp;
+ }
+ }
+ }
+}
+
SWORD_NAMESPACE_END
More information about the sword-cvs
mailing list