home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / Palettes / TTools / TToolsPalette / Utilities.subproj / StorageAdditions.m < prev   
Encoding:
Text File  |  1993-11-09  |  685 b   |  33 lines

  1. /* StorageAdditions.m
  2.  * Written By:  Thomas Burkholder
  3.  *
  4.  * You may freely copy, distribute, and reuse the code in this example.
  5.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  6.  * fitness for any particular use.
  7.  */
  8.  
  9. #import "StorageAdditions.h"
  10. #define NX_NOT_IN_STORAGE -1
  11.  
  12. @implementation Storage (StorageAdditions)
  13.  
  14. - (unsigned int)indexOf:(void *)anElement
  15. {
  16.     int i;
  17.  
  18.     for(i=0;(i<numElements);i++) {
  19.         if (*(long *)anElement == *(long *)[self elementAt:i])
  20.             return i;
  21.     }
  22.     return NX_NOT_IN_STORAGE;
  23. }
  24.  
  25. - addElementIfAbsent:(void *)anElement
  26. {
  27.     if (NX_NOT_IN_STORAGE == [self indexOf:anElement])
  28.         [self addElement:anElement];
  29.     return self;
  30. }
  31.  
  32. @end
  33.