1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

libcxx std::hash 実装のメモ

Posted at

C++11 は unordered_map や unordered_set で便利になりましたが, その背景には std::hash の導入があります.

しかし std::hash の実装自体はややこしいものです.
ここでは libcxx(libc++)の実装を見てみます.

string

__string という名前のヘッダファイルの __do_string_hash に実装があります.

アルゴリズムとしては 32bit (size_t が 32bit の場合) では murmur2, 64bit では cityhash を使っています.
この実装は <utility> にあります.

CityHash の情報はこちら

https://github.com/google/cityhash
http://web.stanford.edu/class/ee380/Abstracts/121017-slides.pdf

イマドキに hash を一から実装するのであれば SipHash https://131002.net/siphash/ が良さそうな気もしますがどうかしらん?

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?