aboutsummaryrefslogtreecommitdiffstats
path: root/Source/NSMutableArray-MultipleSort.h
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-07-28 01:02:40 +0000
committerrowanbeentje <rowan@beent.je>2009-07-28 01:02:40 +0000
commit9c06d1219c66acc043b5f13ab29379f60eb00350 (patch)
tree57f6a57ad8a10552eb22a372fdbf297522d39d65 /Source/NSMutableArray-MultipleSort.h
parent9b827edbb16a50f3e0c42e0f1c21a9bca3e7a77b (diff)
downloadsequelpro-9c06d1219c66acc043b5f13ab29379f60eb00350.tar.gz
sequelpro-9c06d1219c66acc043b5f13ab29379f60eb00350.tar.bz2
sequelpro-9c06d1219c66acc043b5f13ab29379f60eb00350.zip
Improve TablesList significantly:
- If there are twenty or more tables, show a table quicksearch/filter at the top of the list, and update the rest of the code to match. This addresses issue #178. - Select tables and views alphabetically by user's current locale (instead of default MySQL "A B C a b c") - When adding or duplicating tables, insert them at the correct point - Fix a number of minor display bugs caused by incorrect interaction with the tables list caches
Diffstat (limited to 'Source/NSMutableArray-MultipleSort.h')
-rw-r--r--Source/NSMutableArray-MultipleSort.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/Source/NSMutableArray-MultipleSort.h b/Source/NSMutableArray-MultipleSort.h
new file mode 100644
index 00000000..91c8f3f2
--- /dev/null
+++ b/Source/NSMutableArray-MultipleSort.h
@@ -0,0 +1,54 @@
+//
+// NSMutableArray-MultipleSort.h
+// iContractor
+//
+// Created by Jeff LaMarche on 1/16/09.
+// Copyright 2009 Jeff LaMarche. All rights reserved.
+//
+
+// This category on NSMutableArray implements a shell sort based on the old NeXT example
+// SortingInAction. It is functionally identical to sortArrayUsingSelector: except that
+// it will sort other paired arrays based on the comparison values of the original array
+// this is for use in paired array situations, such as when you use one array to store
+// keys and another array to store values. This is a variadic method, so you can sort
+// as many paired arrays as you have.
+
+// This source may be used, free of charge, for any purposes. commercial or non-
+// commercial. There is no attribution requirement, nor any need to distribute
+// your source code. If you do redistribute the source code, you must
+// leave the original header comments, but you may add additional ones.
+
+
+// Stride factor defines the size of the shell sort loop's stride. It can be tweaked
+// for performance, though 3 seems to be a good general purpose value
+#define STRIDE_FACTOR 3
+
+#import <Foundation/Foundation.h>
+
+// This compare method was taken from the GNUStep project. GNUStep is
+// licensed under the LGPL, which allows such use.
+static inline NSComparisonResult compare(id elem1, id elem2, void* context)
+{
+ NSComparisonResult (*imp)(id, SEL, id);
+
+ if (context == 0) {
+ [NSException raise: NSInvalidArgumentException
+ format: @"compare null selector given"];
+ }
+
+ imp = (NSComparisonResult (*)(id, SEL, id))
+ [elem1 methodForSelector: context];
+
+ if (imp == NULL) {
+ [NSException raise: NSGenericException
+ format: @"invalid selector passed to compare"];
+ }
+
+ return (*imp)(elem1, context, elem2);
+}
+
+@interface NSMutableArray(MultipleSort)
+
+// Takes a comparator and a nil-terminated list of paired arrays
+- (void)sortArrayUsingSelector:(SEL)comparator withPairedMutableArrays:(NSMutableArray *)array1, ...;
+@end