Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. String uri = "Some URI"
  2. public int hashCode() {
  3. return uri.hashCode();
  4. }
  5.  
  6. #include <boost/functional/hash.hpp>
  7.  
  8. int hashCode()
  9. {
  10. boost::hash<std::string> string_hash;
  11.  
  12. return string_hash("Hash me");
  13. }
  14.  
  15. std::hash<std::string>()("foo");
  16.  
  17. public int hashCode()
  18. {
  19. int h = hash;
  20. if (h == 0 && count > 0)
  21. {
  22. int off = offset;
  23. char val[] = value;
  24. int len = count;
  25.  
  26. for (int i = 0; i < len; i++)
  27. {
  28. h = 31*h + val[off++];
  29. }
  30. hash = h;
  31. }
  32. return h;
  33. }
  34.  
  35. boost::hash<std::string> string_hash;
  36.  
  37. std::size_t h = string_hash("Hash me");
  38.  
  39. int hashCode(QString text){
  40. int hash = 0, strlen = text.length(), i;
  41. QChar character;
  42. if (strlen == 0)
  43. return hash;
  44. for (i = 0; i < strlen; i++) {
  45. character = text.at(i);
  46. hash = (31 * hash) + (character.toAscii());
  47. }
  48. return hash;
  49. }
  50.  
  51. int HashCode (const std::string &str) {
  52. int h = 0;
  53. for (size_t i = 0; i < str.size(); ++i)
  54. h = h * 31 + static_cast<int>(str[i]);
  55. return h;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement