home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Source / MiscStorage.m < prev    next >
Encoding:
Text File  |  1994-03-22  |  1.4 KB  |  95 lines

  1. //
  2. //    MiscStorage.m -- a Storage subclass with a cursor
  3. //        Written by Doug McClure (c) 1994 by Doug McClure.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This object is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. /*
  15.  * $RCSfile$
  16.  *
  17.  * $Author$
  18.  *
  19.  * $Revision$
  20.  *
  21.  * $Date$
  22.  *
  23. */
  24.  
  25. #import <misckit/MiscStorage.h>
  26.  
  27. #define MiscStorageVersion    100
  28.  
  29. @implementation MiscStorage
  30.  
  31. - (unsigned int)currentPosition
  32. {
  33.   return cursor;
  34. }
  35.  
  36.  
  37. - (void *)setFirstElement
  38. {
  39.   if ( [self count] )
  40.     {
  41.       cursor = 0;
  42.       return [self elementAt:cursor];
  43.     }
  44.   
  45.   return nil;
  46. }
  47.  
  48.  
  49. - (void *)setLastElement
  50. {
  51.   if ( [self count] )
  52.     {
  53.       cursor = [self count] - 1;
  54.       return [self elementAt:cursor];
  55.     }
  56.   
  57.   return nil;
  58. }
  59.  
  60.  
  61. - (void *)setNextElement
  62. {
  63.   if ( (cursor+1) < [self count] )
  64.     {
  65.       return [self elementAt:(++cursor)];
  66.     }
  67.   
  68.   return nil;
  69. }
  70.  
  71.  
  72. - (void *)setPreviousElement
  73. {
  74.   if ( cursor != 0 )
  75.     {
  76.       return [self elementAt:(--cursor)];
  77.     }
  78.  
  79.   return nil;
  80. }
  81.  
  82.  
  83. - (void *)setTo:(unsigned int)aPosition
  84. {
  85.   if ( aPosition < [self count] )
  86.     {
  87.       cursor = aPosition;
  88.       return [self elementAt:cursor];
  89.     }
  90.  
  91.   return nil;
  92. }
  93.  
  94. @end
  95.