home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / src / collate.cpp < prev    next >
C/C++ Source or Header  |  2001-09-30  |  2KB  |  84 lines

  1. /*
  2.  * Copyright (c) 1999
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Copyright (c) 1999 
  6.  * Boris Fomitchev
  7.  *
  8.  * This material is provided "as is", with absolutely no warranty expressed
  9.  * or implied. Any use is at your own risk.
  10.  *
  11.  * Permission to use or copy this software for any purpose is hereby granted 
  12.  * without fee, provided the above notices are retained on all copies.
  13.  * Permission to modify the code and to distribute modified code is granted,
  14.  * provided the above notices are retained, and a notice that the code was
  15.  * modified is included with the above copyright notice.
  16.  *
  17.  */ 
  18. # include "stlport_prefix.h"
  19.  
  20. #include "stl/_collate.h"
  21.  
  22. _STLP_BEGIN_NAMESPACE
  23.  
  24. // collate<char>
  25.  
  26. collate<char>::~collate() {}
  27.  
  28. int collate<char>::do_compare(const char* low1, const char* high1,
  29.                               const char* low2, const char* high2) const
  30. {
  31.   return __lexicographical_compare_3way(low1, high1, low2, high2);
  32. }
  33.  
  34. string collate<char>::do_transform(const char* low, const char* high) const
  35. {
  36.   return string(low, high);
  37. }
  38.  
  39. long collate<char>::do_hash(const char* low, const char* high) const {
  40.   unsigned long result = 0;
  41.   for ( ; low < high; ++low)
  42.     result = 5 * result + *low;
  43.   return result;
  44. }
  45.  
  46.  
  47.  
  48.  
  49. # ifndef _STLP_NO_WCHAR_T
  50. // collate<wchar_t>
  51.  
  52. collate<wchar_t>::~collate() {}
  53.  
  54. int
  55. collate<wchar_t>::do_compare(const wchar_t* low1, const wchar_t* high1,
  56.                              const wchar_t* low2, const wchar_t* high2) const
  57. {
  58.   return __lexicographical_compare_3way(low1, high1, low2, high2);
  59. }
  60.  
  61.  
  62. wstring
  63. collate<wchar_t>::do_transform(const wchar_t* low, const wchar_t* high) const
  64. {
  65.   return wstring(low, high);
  66. }
  67.  
  68. long collate<wchar_t>::do_hash(const wchar_t* low, const wchar_t* high) const
  69. {
  70.   unsigned long result = 0;
  71.   for ( ; low < high; ++low)
  72.     result = 5 * result + *low;
  73.   return result;
  74. }
  75. # endif
  76.  
  77. _STLP_END_NAMESPACE
  78.  
  79.  
  80. // Local Variables:
  81. // mode:C++
  82. // End:
  83.  
  84.