This is SortedList.h in view mode; [Download] [Up]
/*########################################################### Written by Don McGregor Version 1.0, Feb 1992. This code is free for any use. GNU copyleft rules apply. This code has no warrantability of fitness for a particular use, I am not responsible for any damage to data that might be caused by bugs, etc, etc. I encourage others to examine and improve on this code, and to post the improvements to the net. Don McGregor, mcgregdr@conan.ie.orst.edu (for now). $Id: SortedList.h,v 1.2 93/10/27 23:44:23 ediger Exp Locker: ediger $ $Log: SortedList.h,v $ * Revision 1.2 93/10/27 23:44:23 ediger * SortedList that handles "unsigned longs" as one of the built-in data * types it sorts on. Still doesn't sort correctly, though. * ###########################################################*/ #import <objc/Object.h> #import <objc/List.h> #import <appkit/Text.h> #import <objc/HashTable.h> //Sort order, by rising value or falling value #define ASCENDING 0 #define DESCENDING 1 //type of data the order is maintained by #define INT 0 #define ATOM 1 #define DOUBLE 2 #define FLOAT 3 #define OTHER 4 #define UNSIGNED_LONG 5 #define CURRENT_SORTED_LIST_VERSION 1 @interface SortedList:List { int sortOrder; //ascending or descending BOOL caseSensitive; //case sensitive string ordering or not SEL keyMethod; //the method that returns the value the list //is sorted by int keyDataType; //the type of value returned by the keyMethod //(eg, numeric, NXAtom, etc.) } + initialize; //sets class version - initCount:(unsigned int)numSlots; //initialization - setKeyMethod:(SEL)theMethod; //sets method the list is sorted by - (SEL)keyMethod; //returns same - setSortOrder:(int)theSortOrder; //the sort order, asc or desc - (int)sortOrder; //returns the sort order - setCaseSensitive:(BOOL)isIt; //whether strings are case senstive - (BOOL)caseSensitive; - setKeyDataType:(int)theKeyDataType; //sets type of key data - (int)keyDataType; //returns type of key data - printKeyValues; //useful for debugging - addObject:anObject; //slap a new object into list - addObjectIfAbsent:anObject; //override of List method - (int)compare:thisObject to:thatObject;//compare operator on keys - (BOOL)isEqual:anObject; //similar to List op - copy; //override of List - copyFromZone:(NXZone*)zone; - insertionSort; /*-------------------------------------- Methods that are NOT implemented since they make no sense for a sorted list. Attempting to call these will result in a runtime error. --------------------------------------*/ - insertObject:anObject at:(unsigned int)index; - replaceObjectAt:(unsigned int)index with:newObject; - replaceObject:anObject with:newObject; /*-------------------------------------- Archiving methods --------------------------------------*/ -write:(NXTypedStream*)stream; - read:(NXTypedStream*)stream; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.