home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / DevTools / MachOViewer / Source / SortedList.h < prev    next >
Encoding:
Text File  |  1993-10-27  |  2.9 KB  |  107 lines

  1.  
  2. /*###########################################################
  3.     Written by Don McGregor  Version 1.0, Feb 1992.
  4.  
  5.     This code is free for any use.  GNU copyleft
  6.     rules apply.  This code has no warrantability
  7.     of fitness for a particular use, I am not 
  8.     responsible for any damage to data that might
  9.     be caused by bugs, etc, etc. 
  10.     
  11.     I encourage others to examine and improve on this
  12.     code, and to post the improvements to the net.
  13.  
  14.     Don McGregor, mcgregdr@conan.ie.orst.edu (for now).
  15.  
  16.     $Id: SortedList.h,v 1.2 93/10/27 23:44:23 ediger Exp Locker: ediger $
  17.     $Log:    SortedList.h,v $
  18.  * Revision 1.2  93/10/27  23:44:23  ediger
  19.  * SortedList that handles "unsigned longs" as one of the built-in data
  20.  * types it sorts on.  Still doesn't sort correctly, though.
  21.  * 
  22.  
  23.  ###########################################################*/
  24.  
  25.  
  26. #import <objc/Object.h>
  27. #import <objc/List.h>
  28. #import <appkit/Text.h>
  29. #import <objc/HashTable.h>
  30.  
  31.     //Sort order, by rising value or falling value
  32.     
  33. #define ASCENDING    0
  34. #define    DESCENDING    1
  35.  
  36.     //type of data the order is maintained by
  37.     
  38. #define    INT        0
  39. #define    ATOM        1
  40. #define    DOUBLE        2
  41. #define FLOAT        3
  42. #define    OTHER        4
  43. #define    UNSIGNED_LONG        5
  44.  
  45. #define    CURRENT_SORTED_LIST_VERSION    1
  46.  
  47. @interface SortedList:List
  48. {  
  49.   int    sortOrder;    //ascending or descending
  50.   BOOL    caseSensitive;    //case sensitive string ordering or not
  51.   SEL    keyMethod;    //the method that returns the value the list 
  52.               //is sorted by
  53.   int    keyDataType;    //the type of value returned by the keyMethod
  54.               //(eg, numeric, NXAtom, etc.)
  55. }
  56.  
  57. + initialize;                //sets class version
  58.  
  59. - initCount:(unsigned int)numSlots;    //initialization
  60.  
  61. - setKeyMethod:(SEL)theMethod;        //sets method the list is sorted by
  62. - (SEL)keyMethod;            //returns same
  63.  
  64. - setSortOrder:(int)theSortOrder;     //the sort order, asc or desc
  65. - (int)sortOrder;             //returns the sort order
  66.  
  67. - setCaseSensitive:(BOOL)isIt;        //whether strings are case senstive
  68. - (BOOL)caseSensitive;
  69.  
  70. - setKeyDataType:(int)theKeyDataType;    //sets type of key data
  71. - (int)keyDataType;            //returns type of key data
  72.  
  73. - printKeyValues;            //useful for debugging
  74.  
  75. - addObject:anObject;            //slap a new object into list
  76. - addObjectIfAbsent:anObject;        //override of List method 
  77. - (int)compare:thisObject to:thatObject;//compare operator on keys
  78. - (BOOL)isEqual:anObject;        //similar to List op
  79.  
  80. - copy;                    //override of List
  81. - copyFromZone:(NXZone*)zone;
  82.  
  83. - insertionSort;
  84.  
  85.  
  86. /*--------------------------------------
  87.       Methods that are NOT implemented
  88.       since they make no sense for a 
  89.       sorted list.  Attempting to call
  90.       these will result in a runtime error.
  91. --------------------------------------*/
  92.  
  93.  
  94. - insertObject:anObject at:(unsigned int)index;
  95. - replaceObjectAt:(unsigned int)index with:newObject; 
  96. - replaceObject:anObject with:newObject;
  97.  
  98.  
  99. /*--------------------------------------
  100.          Archiving methods
  101. --------------------------------------*/
  102.  
  103. -write:(NXTypedStream*)stream;
  104. - read:(NXTypedStream*)stream;
  105.  
  106. @end
  107.