home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / base / strgset.cxx < prev    next >
C/C++ Source or Header  |  1994-11-12  |  2KB  |  69 lines

  1.  
  2.  
  3.  
  4.  
  5. /*
  6.  *
  7.  *          Copyright (C) 1994, M. A. Sridhar
  8.  *  
  9.  *
  10.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  11.  *     to copy, modify or distribute this software  as you see fit,
  12.  *     and to use  it  for  any  purpose, provided   this copyright
  13.  *     notice and the following   disclaimer are included  with all
  14.  *     copies.
  15.  *
  16.  *                        DISCLAIMER
  17.  *
  18.  *     The author makes no warranties, either expressed or implied,
  19.  *     with respect  to  this  software, its  quality, performance,
  20.  *     merchantability, or fitness for any particular purpose. This
  21.  *     software is distributed  AS IS.  The  user of this  software
  22.  *     assumes all risks  as to its quality  and performance. In no
  23.  *     event shall the author be liable for any direct, indirect or
  24.  *     consequential damages, even if the  author has been  advised
  25.  *     as to the possibility of such damages.
  26.  *
  27.  */
  28.  
  29.  
  30.  
  31.  
  32.  
  33. #if defined(__GNUC__)
  34. #pragma implementation
  35. #endif
  36.  
  37.  
  38. #include "base/setimp.cxx"
  39.  
  40. #if defined(__GNUC__)
  41. template class CL_Set<CL_String>;
  42. template class CL_Iterator<CL_String>;
  43. template class CL_SetIterator<CL_String>;
  44. #endif
  45.  
  46.  
  47. typedef CL_Sequence<CL_String> StringSequence;
  48.  
  49. #include "base/strgset.h"
  50.  
  51. CL_StringSet CL_StringSet::StringsWithPrefix (const CL_String& s) const
  52. {
  53.     CL_StringSet ret;
  54.     if (!_idata)
  55.         return ret;
  56.     StringSequence& _data = (* (StringSequence*) _idata);
  57.     long pos = 0;
  58.     bool b = _data.BinarySearch (s, pos);
  59.     register long n = _data.Size();
  60.     for (register long i = b ? pos : pos+1; i < n; i++) {
  61.         if (!s.IsPrefixOf (_data[i]))
  62.             break;
  63.         ret.Add (_data[i]);
  64.     }
  65.     return ret;
  66. }
  67.  
  68.  
  69.