collate.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #include <locale>
  20. _STLP_BEGIN_NAMESPACE
  21. // collate<char>
  22. collate<char>::~collate() {}
  23. int collate<char>::do_compare(const char* low1, const char* high1,
  24. const char* low2, const char* high2) const
  25. { return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); }
  26. string collate<char>::do_transform(const char* low, const char* high) const
  27. { return string(low, high); }
  28. long collate<char>::do_hash(const char* low, const char* high) const {
  29. unsigned long result = 0;
  30. for ( ; low < high; ++low)
  31. result = 5 * result + *low;
  32. return result;
  33. }
  34. #if !defined (_STLP_NO_WCHAR_T)
  35. // collate<wchar_t>
  36. collate<wchar_t>::~collate() {}
  37. int
  38. collate<wchar_t>::do_compare(const wchar_t* low1, const wchar_t* high1,
  39. const wchar_t* low2, const wchar_t* high2) const
  40. { return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); }
  41. wstring collate<wchar_t>::do_transform(const wchar_t* low, const wchar_t* high) const
  42. { return wstring(low, high); }
  43. long collate<wchar_t>::do_hash(const wchar_t* low, const wchar_t* high) const {
  44. unsigned long result = 0;
  45. for ( ; low < high; ++low)
  46. result = 5 * result + *low;
  47. return result;
  48. }
  49. #endif
  50. _STLP_END_NAMESPACE
  51. // Local Variables:
  52. // mode:C++
  53. // End: