Hash.cpp 554 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // Hash.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/Hash.cpp#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Hashing
  8. // Module: Hash
  9. //
  10. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/Hash.h"
  16. namespace Poco {
  17. std::size_t hash(const std::string& str)
  18. {
  19. std::size_t h = 0;
  20. std::string::const_iterator it = str.begin();
  21. std::string::const_iterator end = str.end();
  22. while (it != end)
  23. {
  24. h = h * 0xf4243 ^ *it++;
  25. }
  26. return h;
  27. }
  28. } // namespace Poco