home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / Classes / SortedList / SortedList.h < prev    next >
Text File  |  1992-02-23  |  3KB  |  99 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.  ###########################################################*/
  17.  
  18.  
  19. #import <objc/Object.h>
  20. #import <objc/List.h>
  21. #import <appkit/Text.h>
  22. #import <objc/HashTable.h>
  23.  
  24.     //Sort order, by rising value or falling value
  25.     
  26. #define ASCENDING    0
  27. #define    DESCENDING    1
  28.  
  29.     //type of data the order is maintained by
  30.     
  31. #define    INT        0
  32. #define    ATOM        1
  33. #define    DOUBLE        2
  34. #define FLOAT        3
  35. #define    OTHER        4
  36.  
  37. #define    CURRENT_SORTED_LIST_VERSION    1
  38.  
  39. @interface SortedList:List
  40. {  
  41.   int    sortOrder;    //ascending or descending
  42.   BOOL    caseSensitive;    //case sensitive string ordering or not
  43.   SEL    keyMethod;    //the method that returns the value the list 
  44.               //is sorted by
  45.   int    keyDataType;    //the type of value returned by the keyMethod
  46.               //(eg, numeric, NXAtom, etc.)
  47. }
  48.  
  49. + initialize;                //sets class version
  50.  
  51. - initCount:(unsigned int)numSlots;    //initialization
  52.  
  53. - setKeyMethod:(SEL)theMethod;        //sets method the list is sorted by
  54. - (SEL)keyMethod;            //returns same
  55.  
  56. - setSortOrder:(int)theSortOrder;     //the sort order, asc or desc
  57. - (int)sortOrder;             //returns the sort order
  58.  
  59. - setCaseSensitive:(BOOL)isIt;        //whether strings are case senstive
  60. - (BOOL)caseSensitive;
  61.  
  62. - setKeyDataType:(int)theKeyDataType;    //sets type of key data
  63. - (int)keyDataType;            //returns type of key data
  64.  
  65. - printKeyValues;            //useful for debugging
  66.  
  67. - addObject:anObject;            //slap a new object into list
  68. - addObjectIfAbsent:anObject;        //override of List method 
  69. - (int)compare:thisObject to:thatObject;//compare operator on keys
  70. - (BOOL)isEqual:anObject;        //similar to List op
  71.  
  72. - copy;                    //override of List
  73. - copyFromZone:(NXZone*)zone;
  74.  
  75. - insertionSort;
  76.  
  77.  
  78. /*--------------------------------------
  79.       Methods that are NOT implemented
  80.       since they make no sense for a 
  81.       sorted list.  Attempting to call
  82.       these will result in a runtime error.
  83. --------------------------------------*/
  84.  
  85.  
  86. - insertObject:anObject at:(unsigned int)index;
  87. - replaceObjectAt:(unsigned int)index with:newObject; 
  88. - replaceObject:anObject with:newObject;
  89.  
  90.  
  91. /*--------------------------------------
  92.          Archiving methods
  93. --------------------------------------*/
  94.  
  95. -write:(NXTypedStream*)stream;
  96. - read:(NXTypedStream*)stream;
  97.  
  98. @end
  99.