home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / db02_src.zip / search.cc < prev    next >
C/C++ Source or Header  |  1993-11-05  |  542b  |  44 lines

  1. #include <malloc.h>
  2.  
  3. int headerSize(void)
  4. {
  5.     return sizeof(headerData);
  6. }
  7.  
  8. int tupleSize(void)
  9. {
  10.     return keyLength + sizeof(void *);
  11. }
  12.  
  13. keyType* getKeyAddr(int pos)
  14. {
  15.     keyType* key = (keyType*)(data + pos * tupleSize() + sizeof(long));
  16.     return key;
  17. }
  18.  
  19.  
  20.  
  21. long* getLinkAddr(int pos)
  22. {
  23.     long* link = firstTuple()+pos*tupleSize();
  24.     return link;
  25. }
  26.  
  27. bool searchForKey(object& theObject, int& ptr)
  28. {
  29.     int i=0;
  30.  
  31.     while (i < activeKeys)
  32.     {    
  33.         if (theObject.isLess(getKeyAddr(i))
  34.         {
  35.             ptr = i;
  36.             return TRUE;
  37.         }
  38.         i++;
  39.     }
  40.     ptr=i;
  41.     return FALSE;
  42. }
  43.  
  44.