home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / C / BPLUS / FIND1STK.C < prev    next >
C/C++ Source or Header  |  1993-12-01  |  1KB  |  42 lines

  1. /*****************************************************************
  2.  |  find_1stkey - find first key matching
  3.  |----------------------------------------------------------------
  4.  |  The find_key routine may not return a pointer to the first
  5.  |  matching key in terms of next_key order. To allow searching
  6.  |  of all matching keys, use get_1stkey and next_key.
  7.  |----------------------------------------------------------------
  8.  |  Arguments:
  9.  |   1) pointer to the ENTRY struct
  10.  |   2) pointer to the IX_DESC struct
  11.  ****************************************************************/
  12.  
  13. #include "bplus.h"
  14.  
  15. int
  16. find_1stkey(wkptr, ixptr)
  17.     ENTRY *wkptr;
  18.     IX_DESC *ixptr;
  19. {
  20.     ENTRY lastok;               /* last matching entry      */
  21.     IX_DESC ixwk;               /* last valid index value   */
  22.     int stat;
  23.  
  24.     if ((stat = find_key(wkptr, ixptr)) == IX_OK)
  25.     {
  26.         lastok = *wkptr;
  27.         ixwk = *ixptr;
  28.         
  29.         while (prev_key(wkptr, ixptr) != EOIX &&
  30.             strcmp(wkptr->key, lastok.key) == 0)
  31.         {
  32.             lastok = *wkptr;
  33.             ixwk = *ixptr;
  34.     }
  35.  
  36.         *wkptr = lastok;
  37.         *ixptr = ixwk;
  38.      }
  39.      return stat;
  40. }
  41.  
  42.