You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
(訳注:2016/9/28、頂きましたフィードバックを元に記事を修正いたしました。) はじめに 本稿では、高速で汎用的なハッシュテーブルを作るために行う、設計についての多くの意思決定事項を紹介します。最終的に、私の emilib::HashSet とC++11の std::unordered_set の間のベンチマークが出来上がりました。もし、ハッシュテーブルに興味があって、自分で設計したいなら(どのプログラミング言語かに関わらず)、本稿がヒントになるかもしれません。 ハッシュテーブル は、素晴らしい発明です。 ならし計算量O(1) ( O(√N)時間 )で、挿入、削除、検索を行うことができます。ならし計算量とは、ハッシュテーブルの計算に平均でO(1)の計算量がかかることを意味しますが、時々、これよりも多くの時間がかかる場合があります。具体的には、ハッシュテーブルに空きがない場合で、挿入の
文字列のハッシュをconstexprで計算できればC++で文字列を使ったswitchができるんだけどなあと思ったけど,mpl::stringならコンパイル時にハッシュ値の計算できたりしないだろうか. 2011-01-14 19:48:06 via P3:PeraPeraPrv 「なるほどー」と思ったので文字列のハッシュを使う実験。 #include<string> #include<iostream> constexpr int hash(char const * s) { return *s ? *s + hash(s + 1) : 0; // 超絶てけとーハッシュ } int main() { for(std::string s; std::cin >> s;) switch(hash(s.c_str())) { case hash("foo"): std::cout << "case
前回のエントリで紹介したBundleSaverを作成する際に、SparseArrayというクラスの存在を知りました。 SparseArrayは、Android向けにつくられたパフォーマンスに優れたHashMap代用とのことで、その使い方と気になる性能について調べてみました。 実際に測定することでメリットやデメリットがわかったので、ご紹介します。 SparseArrayってなぁに? どう使うの? HashMap と SparseArray の性能比較 考察 まとめ 参考(計測に利用したクラス) 1. SparseArrayってなぁに? SparseArrayは、キーにintを利用することを前提としたHashMapだと考えると分かりやすいかと思います。 (Integerではなく、intです。) また、SparseArrayでは、値にObject型を格納できますが、値がint, booleanの
(ε・◇・)з hasOwnProperty を使った for in ループより 20%~84% 低コストな、うーぱー式 ループのご紹介だよ~ Object.keys を使い、key を列挙することで、hasOwnProperty を使った for in ループよりも速くなります。 var keys = Object.keys(obj), i = 0, iz = keys.length; for (; i < iz; ++i) { var key = keys[i]; var value = obj[key]; ... ベンチマーク http://jsperf.com/perf-for-in-loop-vs-pre-enum-keys-for-loop/8 Browser for_in_hasOwnProperty loop uupaa-looper Chrome 16.0.912.77
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く